Change System.init to return a promise to cope with asynchronous platform initialization#266
Open
purplepwny wants to merge 1 commit intoaduros:masterfrom
Open
Change System.init to return a promise to cope with asynchronous platform initialization#266purplepwny wants to merge 1 commit intoaduros:masterfrom
purplepwny wants to merge 1 commit intoaduros:masterfrom
Conversation
… initialization that may be asynchronous. 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, due a Context3D not yet being available. With this change, we can wait for a platform to become ready before continuing with other work.
Owner
|
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. |
Contributor
|
I vote for magic 🌟 |
Contributor
Author
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.