Author Topic: Context changed  (Read 3297 times)

Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
Context changed
« on: March 14, 2013, 01:39:57 pm »
Is really needed upload all textures and compile shaders again after context changed? Many games from play store are running immediately after I back into game. And please, could you compile default shaders only when are needed, or maybe when is called FrameBuffer.compileDefaultShaders() or GLSLShader.compile()? Compilation of default shaders take on lower devices almost 2 seconds and I do not use any of them.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Context changed
« Reply #1 on: March 14, 2013, 03:10:57 pm »
Yes, it's needed. There's nothing else i could do. If the context is lost, the data is lost. IF the context is actually lost, is another question. If you are sure that it's not lost, don't create a new FrameBuffer instance. However, we already had some problems with that kind of "optimization", so personally, i would live with the time it takes to upload the stuff again and be sure that it runs on different devices and different Android versions.

About the shaders...you are using at least one of them if you are using blitting. I'm not going to make this fully optional ATM, but i'll look into some Config hack to avoid using them altogether, if one doesn't want them.
« Last Edit: March 14, 2013, 03:13:01 pm by EgonOlsen »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Context changed
« Reply #2 on: March 14, 2013, 03:26:56 pm »
I've updated the beta jar with a version that adds a switch to Config. Set Config.skipDefaultShaders=true; and only two default shaders will be compiled. If you are using any other, it will print out a warning message and uses the generic default instead, which will be slower.

Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
Re: Context changed
« Reply #3 on: March 14, 2013, 10:58:31 pm »
Thanks ;) I added code to prevent lost GL content, so app is back instantly.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Context changed
« Reply #4 on: March 14, 2013, 11:41:00 pm »
...nut be prepared that this might not work on all devices...

Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
Re: Context changed
« Reply #5 on: March 15, 2013, 12:06:02 am »
If will be lost, be loaded again, I hope...

Offline raft

  • quad
  • ******
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: Context changed
« Reply #6 on: March 21, 2013, 10:34:43 pm »
...nut be prepared that this might not work on all devices...
Why is that? I'm also curious about this. Isnt there any reliable way of detecting if context is lost or not?

If even not, if system throws a specific or distinguishable exception when trying to access a lost context, that can be caught and a new context might be created, right?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Context changed
« Reply #7 on: March 21, 2013, 11:04:42 pm »
In theory, yes. But i remember one case (from a user, not experienced this myself) where the gl instance remained the same but the data was lost anyway. Treating the "old" context as a new one solved the issue.