App crash when come back

Lifecycle management



Leaving the activity with the Home key freezes the app in the background. When you return, the app is in the same state as when you left it (pause).



But when i return ,the app will be crash.what’s wrong?

logcat:

[xml]

04-06 11:58:24.866 8907 8916 E AndroidHarness: java.lang.RuntimeException: Canvas: trying to use a recycled bitmap android.graphics.Bitmap@45e52ec8

04-06 11:58:24.889 8907 8916 E AndroidHarness: SEVERE AndroidHarness 11:58:24 Exception thrown in Thread[GLThread 10,5,main]: at android.graphics.Canvas.throwIfRecycled(955)

04-06 11:58:24.889 8907 8916 E AndroidHarness: at android.graphics.Canvas.drawBitmap(1012)

04-06 11:58:24.889 8907 8916 E AndroidHarness: at android.graphics.Bitmap.createBitmap(483)

04-06 11:58:24.889 8907 8916 E AndroidHarness: at android.graphics.Bitmap.createScaledBitmap(370)

04-06 11:58:24.889 8907 8916 E AndroidHarness: at com.jme3.renderer.android.TextureUtil.uploadTextureBitmap(95)

04-06 11:58:24.889 8907 8916 E AndroidHarness: at com.jme3.renderer.android.TextureUtil.uploadTexture(123)

04-06 11:58:24.889 8907 8916 E AndroidHarness: at com.jme3.renderer.android.OGLESShaderRenderer.updateTexImageData(1910)

04-06 11:58:24.889 8907 8916 E AndroidHarness: at com.jme3.renderer.android.OGLESShaderRenderer.setTexture(1945)

04-06 11:58:24.889 8907 8916 E AndroidHarness: at com.jme3.material.MatParamTexture.apply(46)

04-06 11:58:24.889 8907 8916 E AndroidHarness: at com.jme3.material.Material.render(1009)

04-06 11:58:24.889 8907 8916 E AndroidHarness: at com.jme3.renderer.RenderManager.renderGeometry(649)

04-06 11:58:24.889 8907 8916 E AndroidHarness: at com.jme3.renderer.queue.RenderQueue.renderGeometryList(299)

04-06 11:58:24.889 8907 8916 E AndroidHarness: at com.jme3.renderer.queue.RenderQueue.renderQueue(351)

04-06 11:58:24.889 8907 8916 E AndroidHarness: at com.jme3.renderer.RenderManager.renderViewPortQueues(886)

04-06 11:58:24.889 8907 8916 E AndroidHarness: at com.jme3.renderer.RenderManager.flushQueue(842)

04-06 11:58:24.889 8907 8916 E AndroidHarness: at com.jme3.renderer.RenderManager.renderViewPort(1118)

04-06 11:58:24.889 8907 8916 E AndroidHarness: at com.jme3.renderer.RenderManager.render(1160)

04-06 11:58:24.889 8907 8916 E AndroidHarness: at com.jme3.app.SimpleApplication.update(266)

04-06 11:58:24.889 8907 8916 E AndroidHarness: at com.jme3.system.android.OGLESContext.onDrawFrame(412)

04-06 11:58:24.889 8907 8916 E AndroidHarness: at android.opengl.GLSurfaceView$GLThread.guardedRun(1332)

04-06 11:58:24.889 8907 8916 E AndroidHarness: at android.opengl.GLSurfaceView$GLThread.run(1116)[/xml]

mhhh you seem to use a texture that is not loaded by JME’s assetManager, but by android. Android may recycle the memory allocated to resources when your activity is paused. That’s probably what’s going on here.



Why don’t you load your textures with the assetManager?

@nehon said:
mhhh you seem to use a texture that is not loaded by JME's assetManager, but by android. Android may recycle the memory allocated to resources when your activity is paused. That's probably what's going on here.

Why don't you load your textures with the assetManager?


I just try a model without texture and it's ok now.
But if i import a model with SDK, it will be crash. The texture goes into models automatic and i do nothing with the texture in my code.
Did i misunderstand import Model in the SDK?

What is your model? a j3o?

Are you using the nightly/SVN version of jME3? This was fixed recently.