DaVikingCode/Citrus-Engine

StarlingCE : Provide a nice way to react to a lost context.

Closed this issue · 0 comments

UPDATE :
it is a misconception on my part to think that we wil have enough time between context loss and re-creation to do anything on the display list as it is now pretty much instantaneously, what takes time though, is textures being restored which is completely different and can in fact take seconds.


Starling.as does listen for stage3D errors and the errorID 3702 corresponds to a lost context (or device/os problem which causes the context to be lost anyway so it can be assimilated) StarlingCitrusEngine could automatically listen for that specific error to provide a nice API so that we can for example hide the app with a native display list "loading screen" or do something else to distract the user until the next context3D created event.

we can even provide a "on context restored" provided that a context was active in the first place, perhaps using a simple boolean switch

Extract from Starling.as

        private function onStage3DError(event:ErrorEvent):void
        {
            if (event.errorID == 3702)
            {
                var mode:String = Capabilities.playerType == "Desktop" ? "renderMode" : "wmode";
                showFatalError("Context3D not available! Possible reasons: wrong " + mode +
                               " or missing device support.");
            }
            else
                showFatalError("Stage3D error: " + event.text);
        }