XTDStudios / DMT

Dynamically Mapping Textures
101 stars 13 forks source link

Handling Error #3768 on IOS #23

Open idanasher opened 7 years ago

idanasher commented 7 years ago

First of all - I am using the DMT already for my android game- works great !! loving it ! Thanks a lot Gil (and XTDStudios) for your continued efforts...

I am performing testing on ipad\iphone devicesnow before launching my game and I have this problem whenever a DMT instance is still processing graphics - I exit the app (background). this always results on this error:

Error: Error #3768: The Stage3D API may not be used during background execution on this operating system. at ConcreteRectangleTexture/uploadBitmapData()[/Users/redge/Dropbox/Development/starling-2/starling/src/starling/textures/ConcreteRectangleTexture.as:38] at starling.textures::Texture$/fromBitmapData()[/Users/redge/Dropbox/Development/starling-2/starling/src/starling/textures/Texture.as:321] at com.xtdstudios.DMT.starlingConverter::StarlingConverter/init()[C:\Client\Flash\Libraries\PkamaLib\V_6_STAR\com\xtdstudios\DMT\starlingConverter\StarlingConverter.as:75] at com.xtdstudios.DMT::DMTBasic/processTextures()[C:\Client\Flash\Libraries\PkamaLib\V_6_STAR\com\xtdstudios\DMT\DMTBasic.as:119] at com.xtdstudios.DMT::DMTAbsAPI/onTexturesReady()[C:\Client\Flash\Libraries\PkamaLib\V_6_STAR\com\xtdstudios\DMT\DMTAbsAPI.as:274] at com.xtdstudios.DMT::DMTAbsAPI/onGenerateComplete()[C:\Client\Flash\Libraries\PkamaLib\V_6_STAR\com\xtdstudios\DMT\DMTAbsAPI.as:269] at com.xtdstudios.DMT::DMTAbsAPI/onGenerateComplete()

The DMT tries to render textures while app is in background.

But I have notice this: on StarlingConverter.init function - you have this Try & Catch: ..... catch (e:Error) { // we will ignore any error in case the context was diposed when creating the textures // the context should be re-created anyways. if (Starling.context && Starling.context.driverInfo != "Disposed") throw e; }

As I see it, in order to ignore this scenario as well, we should check the 'Starling.current.isStarted' result as well, thus resulting in this:

if (Starling.context && Starling.context.driverInfo != "Disposed" && Starling.current.isStarted)

In this way, we will avoid having this error thrown in this case. we can also check this condition before 'Texture.fromBitmapData' ....

In addition, I have found out that it is wise, on the 'dmtComplete' event to check weather your app is active\deactivate. and if it is suspended (on background) then I handle this manully... and continue the flow of generating graphics and using the dmt's created assets.

This bug has troubled me a lot lately, and I hope this sharing will help resolving this for others as well.

gilamran commented 7 years ago

It would be great if you could create a pull request will all the implementation that you mentioned so others will also benefit from it. Thanks for the contribution!

idanasher commented 7 years ago

ok, but I can't seem to understand what to choose here in order to submit the pull request:

On Wed, Sep 21, 2016 at 12:23 PM, Gil Amran notifications@github.com wrote:

It would be great if you could create a pull request will all the implementation that you mentioned so others will also benefit from it. Thanks for the contribution!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/XTDStudios/DMT/issues/23#issuecomment-248557839, or mute the thread https://github.com/notifications/unsubscribe-auth/AHz2HUQFoHNM9xhRlo_5GLSjrvfyudygks5qsPeggaJpZM4KCkyk .

gilamran commented 7 years ago

feel free to ask if it's not clear

thanks