flambe icon indicating copy to clipboard operation
flambe copied to clipboard

Change System.init to return a promise to cope with asynchronous platform initialization

Open purplepwny opened this issue 10 years ago • 3 comments

FlashPlatform's initialization is actually asynchronous, in that we must wait for Stage3DRenderer to acquire a Context3D before we're ready to roll. Since the Flash platform requires a Context3D before textures can be loaded, quickly loading textures after calling System.init was causing undesirable behavior (null textures), due to a Context3D not yet being available. With this change, we can wait for a platform to become ready before continuing with other work.

purplepwny avatar Jun 24 '14 19:06 purplepwny

Hi, thanks for the patch! What I usually do is to wait for System.renderer.hasGPU to become true, but this seems better.

Another possible idea, what if calling System.init() was unnecessary? We should be able to do some magic to invoke the main method only when the platform is ready.

aduros avatar Jul 07 '14 14:07 aduros

I vote for magic :star2:

markknol avatar Jul 08 '14 08:07 markknol

We should be able to do some magic to invoke the main method only when the platform is ready.

Personally, I'm very new to Haxe so I'm not so up on the magical possibilities, but off the top of my head I'd say:

Alter the build process to feed the Haxe compiler a -main flag that points to a Flambe class that just calls System.init(), waits for the platform to become ready, and then calls out to the user's main class specified in flambe.yaml.

purplepwny avatar Jul 08 '14 12:07 purplepwny