Author Topic: GLSurfaceView slows for a moment  (Read 2090 times)

Offline ramzes0071

  • byte
  • *
  • Posts: 11
    • View Profile
GLSurfaceView slows for a moment
« on: January 19, 2014, 12:25:56 pm »
Hi,

I need some help. I have my game renderer and it works ok, but at some point of time I add another Object3D (it is added to world from the beginning but is invisible, so I change only its visibility) and when it appear, for a moment my game slow down, fps too. This action occurs only when I first time do this manipulation. When I repeat it again everything looks ok. My Object3D is't complex.

I don't know what is going on. Do you have  any solutions for this problem?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: GLSurfaceView slows for a moment
« Reply #1 on: January 19, 2014, 02:19:44 pm »
That's because objects need some processing before they can be displayed. By default, this happens at runtime when the object will be rendered for the first time. You can use World.compileAllObjects() to shift a huge part of that workload to the setup phase.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: GLSurfaceView slows for a moment
« Reply #2 on: January 19, 2014, 02:22:44 pm »
Texture uploads can be another issue. You can use TextureManager.preWarm(...) to pre-upload textures.

Offline ramzes0071

  • byte
  • *
  • Posts: 11
    • View Profile
Re: GLSurfaceView slows for a moment
« Reply #3 on: January 19, 2014, 03:19:07 pm »
I have World.compileAllObjects(), and now I added TextureManager.preWarm(...) .
Looks fine  :)
thx

Offline Irony

  • long
  • ***
  • Posts: 151
    • View Profile
Re: GLSurfaceView slows for a moment
« Reply #4 on: January 31, 2014, 01:23:29 pm »
As this seems to be a relatively common issue, and it's pretty hard to figure out for a beginner, I have added a page to the Wiki under "Advanced topics" (did not want to add it to performance tips as those all seem to be for Android in general, not JPCTAE specific)
Hope that's ok!