Segfault on Linux when adding Tile to Tilemap which has been empty for a while

I have been investigating an issue causing segfaults on Linux when all of these conditions are met:

  • There is a Tilemap which has previously contained Tiles
  • The Tiles have all been removed from the Tilemap and it has been empty for somewhere between minutes and hours (five minutes doesn’t always lead to the crash, overnight does seem to)
  • A new Tile is added to this Tilemap

The crash appears to occur outside the code written for the project - the Tile is added successfully, the code can then go on to do other things, but some time after control is passed back to the rest of the OpenFL system, it segfaults. I’m assuming it’s connected with the operation to draw this newly added Tile on the Tilemap, but I haven’t investigated that deeply.

I’ve only seen it happen natively on Linux - running in Neko does not cause the crash, and so far my tests on Android have not produced the crash. I don’t yet have a Windows system or any others to test on so I don’t know which other systems might be affected.

I’ve made a modified version of the BunnyMark demo which allows the Bunny tiles to be removed as they hop off the edge of the screen, to demonstrate the issue and document how it is reproduced. Hardware and software details are included in that page, copied here for convenience:

  • AMD Desktop with nvidia graphics card and Intel laptop with Intel on-board graphics
  • Linux kernel versions 4.15.9-1-ARCH and 4.15.3-2-ARCH
  • Haxe compiler versions 3.4.7 and 3.4.4
  • hxcpp version 3.4.188
  • lime versions 6.2.0 and 5.9.1
  • openfl versions 7.1.2 and 6.5.3

As mentioned in that repo, it’s easy enough to work around the issue: simply add a Tile to every Tilemap with co-ordinates which place it out of sight, and leave it there for the life of the Tilemap. With this workaround in place I’m going to move on with my project, but I wanted to document and report the issue first.

1 Like

Thank you!

We have given Tilemap a total rewrite in our development version, leading to 9 times increase in performance for some tests. I have a feeling this rework removed some of the complexity (caused by TileArray, which is being deprecated) as there was an extra layer between Tile objects and the renderer.

It would be interesting to test the latest development builds, if that would be possible. How long does it take to reproduce the issue on your test?

1 Like

I’ve installed the development versions of OpenFL and Lime on the laptop, and I’ve been running three different projects without a crash for about the past hour. Previously they all suffered from the crash, usually within five or ten minutes of inactivity followed by adding another Tile. I would say that the issue is fixed!

Also like you said, the performance is greatly improved! I didn’t do a proper before and after comparison, but my impression is that I can add about five times as many Tiles before the frame rate drops below 60fps.

Thank you for the response, and for continuing to make OpenFL such a great system!