Skip to content

Conversation

@ACrazyTown
Copy link
Contributor

This fixes a crash in a project where threaded caching of assets is done immediately upon load. Because it's on a thread, OpenGL freaks out and crashes, though it's interesting to note that the crash only happened on macOS.

I think it's best to just let Flixel query this once when the window is created and then it'll be cached

@Geokureli
Copy link
Member

Can you share a test case that causes the error?

@ACrazyTown
Copy link
Contributor Author

Can you share a test case that causes the error?

class PlayState extends flixel.FlxState
{
	override public function create()
	{
		super.create();

		// by uncommenting the trace here the crash no longer happens
		// the PR does something similar by querying maxTextureSize asap
		// when the window is created

		// trace(FlxG.bitmap.maxTextureSize);

		var f = new lime.app.Future(() -> {
			flixel.FlxG.bitmap.create(1000, 1000, 0);
		}, true);
	}
}
SIGNAL 11
lime._internal.backend.native.NativeOpenGLRenderContext.getInteger(lime/_internal/backend/native/NativeOpenGLRenderContext.hx:1705)
lime._internal.backend.native.NativeOpenGLRenderContext.getParameter(lime/_internal/backend/native/NativeOpenGLRenderContext.hx:1825)
flixel.system.frontEnds.BitmapFrontEnd.get_maxTextureSize(flixel/system/frontEnds/BitmapFrontEnd.hx:349)
flixel.graphics.FlxGraphic.set_bitmap(flixel/graphics/FlxGraphic.hx:612)
flixel.graphics.$FlxGraphic.__constructor__(flixel/graphics/FlxGraphic.hx:410)
flixel.graphics.$FlxGraphic.createGraphic(flixel/graphics/FlxGraphic.hx:252)
flixel.graphics.$FlxGraphic.fromRectangle(flixel/graphics/FlxGraphic.hx:220)
flixel.system.frontEnds.BitmapFrontEnd.create(flixel/system/frontEnds/BitmapFrontEnd.hx:86)
PlayState.~create.0(PlayState.hx:16)
lime.app.$FutureWork.threadPool_doWork(lime/app/Future.hx:349)
lime.app.$FutureWork.~run.0(lime/app/Module.hx:0)
lime.system.$ThreadPool.__executeThread(lime/system/WorkOutput.hx:251)
sys.thread._Thread.$HaxeThread.~create.0(/usr/local/lib/haxe/std/hl/_std/sys/thread/Thread.hx:152)

Like I mentioned above I only started getting this crash when testing on a Mac. Either way I think this falls into "undefined behavior" as OpenGL is meant to be accessed from a single thread only, the Windows OpenGL implementation might just be getting lucky

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants