Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android, lost/restore context #1

Closed
labe-me opened this issue Feb 18, 2014 · 8 comments
Closed

Android, lost/restore context #1

labe-me opened this issue Feb 18, 2014 · 8 comments

Comments

@labe-me
Copy link
Contributor

labe-me commented Feb 18, 2014

Hello, I am testing BabylonHx and it's working quite well on html5, congrats !

I have a problem on Android, when the device is rotated or the application put in the background the opengl context is lost.

openfl sends openfl.display.OpenGLView.CONTEXT_LOST and openfl.display.OpenGLView.CONTEXT_RESTORED events (flash.Lib.current.stage)

Is something planed to automatically restore the context?
If not what do you think is the best way to efficiently restore it by hand?

Thanks,
Laurent

@vujadin
Copy link
Owner

vujadin commented Feb 18, 2014

Hi,

there are more problems with mobile targets then CONTEXT_LOST :(
like incomplete meshes/broken depth-buffer ...

I think that CONTEXT_LOST problem is in OpenFL, not in BabylonHx (its
actually SDL2.0 implementation
problem in OpenFL and @singmajesty said it was fixed but obviously its not

In html5 it runs really nice and I have updated the code (not publised
yet...) to use native arrays for matrix manipulations
in html5 target - with it and some Haxe magic I believe it can actually
outperform original BabylonJs :)

Still a lot of work remains though ...
Thank you for your interest in project.

Regards,
Krtolica Vujadin
GameStudioHx.com

On Tue, Feb 18, 2014 at 1:37 PM, Laurent Bédubourg <notifications@github.com

wrote:

Hello, I am testing BabylonHx and it's working quite well on html5,
congrats !

I have a problem on Android, when the device is rotated or the application
put in the background the opengl context is lost.

openfl sends openfl.display.OpenGLView.CONTEXT_LOST and
openfl.display.OpenGLView.CONTEXT_RESTORED events (flash.Lib.current.stage)

Is something planed to automatically restore the context?
If not what do you think is the best way to efficiently restore it by hand?

Thanks,
Laurent

Reply to this email directly or view it on GitHubhttps://github.com//issues/1
.

@vujadin vujadin mentioned this issue Feb 18, 2014
@labe-me
Copy link
Contributor Author

labe-me commented Feb 18, 2014

"context lost events for Android when using OpenGLView (other platforms retain the GL context during a resize) and other audio fixes."

I think it means: "I send you the event, now that's your problem" :)

I tried to add an event listener on the stage and I indeed received these events (twice by the way).

I know that starling has something similar for android (http://forum.starling-framework.org/topic/new-feature-handling-a-lost-device-context). I imagine we have to reset all cache and resent textures and data to the GPU?

@labe-me labe-me closed this as completed Feb 18, 2014
@labe-me labe-me reopened this Feb 18, 2014
@labe-me
Copy link
Contributor Author

labe-me commented Feb 18, 2014

Sorry, wrong button :)

I'll ask joshua to know exactly what we should expect.

@labe-me
Copy link
Contributor Author

labe-me commented Feb 19, 2014

Got a reply, it looks like an openfl problem, thank you for your time:

@labe_me It's not important for you to address, using you are using GLView directly

— Joshua Granick (@singmajesty) February 19, 2014
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>

@labe-me labe-me closed this as completed Feb 19, 2014
@labe-me
Copy link
Contributor Author

labe-me commented Feb 20, 2014

I am afraid Joshua did not understand my question.

In fact the application must listen to the CONTEXT_RESTORED event (on OpenGLView) and has to be able to recreate its buffers, shaders, etc.

openfl/lime#88

I don't know how much work it represents for BabylonHX but it seems pretty mandatory for Android.

@labe-me labe-me reopened this Feb 20, 2014
@onatbas
Copy link

onatbas commented Feb 23, 2014

I don't think it should be considered as an openFL problem. In my implementation, im not using openfl.Assets at all, just like Laurent stated , starling textures are calling a callback, so you can reload all the textures back. I think there should be a way to load the data to Textures.
I can recreate the textures, but i dont know if there's any way to load data to same Texture instances.

@vujadin
Copy link
Owner

vujadin commented Feb 23, 2014

Well, it shouldn't be considered as BabylonHx problem neither because it exists on every application that uses OpenGLView - try "HerokuShaders" and "SimpleOpenGLView" OpenFl samples.
And only android target has the problem ...
The solution - "recreating the shaders, buffers, etc again", its quite a bit of work on 3D engine such as Babylon... and keeping all the textures and other stuff in memory will increase RAM usage quite a bit.
Locking the game to landscape/portrait and implementing "save game" mechanism and reloading the game from the saved position on CONTEXT_RESTORED is a solution for a project I'm working on right now (for android target). I'm showing "Restoring your game - please wait" message to the user. Its not perfect but its better then black screen ;)

@vujadin
Copy link
Owner

vujadin commented May 8, 2015

Fixed in 2.0

@vujadin vujadin closed this as completed May 8, 2015
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

No branches or pull requests

3 participants