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

Fatal Exception: Error loading texture #3

Open
ParkSangGwon opened this issue Jan 7, 2016 · 9 comments
Open

Fatal Exception: Error loading texture #3

ParkSangGwon opened this issue Jan 7, 2016 · 9 comments

Comments

@ParkSangGwon
Copy link

I got error report from this library.
how can I fix or check code?
is this bug?
I thik this error is not appear all time.
some device occur error

Fatal Exception: java.lang.RuntimeException: Error loading texture.
at com.yalantis.starwars.utils.gl.TextureHelper.loadTexture(TextureHelper.java:53)
at com.yalantis.starwars.render.StarWarsRenderer$2.run(StarWarsRenderer.java:290)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1471)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1248)

@defHLT
Copy link
Contributor

defHLT commented Jan 7, 2016

It occurs when texture can't be generated because of a trashed OpenGL context. One way it can happen when mTilesFrameLayout.startAnimation() is called after mTilesFrameLayout.onPause(). Do you work on your own example? If so please check your onResume/onPause calls or share your code if problem persists. If you're getting this error when running provided demo sample then please share more detailed steps and I'll try to reproduce it.

@ParkSangGwon
Copy link
Author

ok. I will add some code.
when mTilesFrameLayout.startAnimation() is called, I will check mTilesFrameLayout's state ( already onPause() or not )

and I will add try/catch block like this

        if(tiles_frame!=null){

            try {
                tiles_frame.startAnimation();
            }catch(Exception e){
                finish();
                overridePendingTransition(0, 0);
            }

        }

@bradmartin
Copy link

I'm working on taking this library and integrating a plugin for NativeScript and I get the same error when I call .startAnimation() on the instance of TilesFrameLayout view. The app isn't pausing so it's likely some app life cycle that NativeScript implements just not certain. I load the view and then on a click (tap) event I get a reference to the view and call .startAnimation() so I'm not sure about onPause() being called.

@defHLT
Copy link
Contributor

defHLT commented Feb 18, 2016

@bradmartin the only was I can reproduce it if I comment out mTilesFrameLayout.onResume(); call in demo app and then go from and back to activity. That would cause GL thread to pause and texture loading would throw an error unless thread will be resumed before that. Can't think of another reason for this crash right now. Could you debug and ensue onResume call is really happening in right time?

@defHLT
Copy link
Contributor

defHLT commented Feb 18, 2016

@bradmartin the only way I can reproduce it if I comment out mTilesFrameLayout.onResume(); call in demo app and then go from and back to activity. That would cause GL thread to pause and texture loading would throw an error unless thread will be resumed before that. Can't think of another reason for this crash right now. Could you debug and ensue onResume call is really happening in right time?

@defHLT defHLT closed this as completed Feb 18, 2016
@defHLT defHLT reopened this Feb 18, 2016
@bradmartin
Copy link

@mlatu - I've called onResume() and everything seems fine. Can any view be in the layout? I think the bitmap is not being passed correctly to the TextureHelper which is where the RunTimeException is thrown (line 53).

@defHLT
Copy link
Contributor

defHLT commented Feb 22, 2016

@bradmartin Yes, any view can be in the layout. If there are several views - just wrap it in any ViewGroup.

Exception at line 53 is thrown if glGenTextures failed to do its job. It usually happens when there is no OpenGL context available. At this point it never even tries to work with the bitmap because glGenTextures fails. Could you call

int err = GLES20.glGetError();
String msg = GLUtils.getEGLErrorString(err);

just before the throw (after glGenTextures) and see what's the results?

I would do that but I don't have your setup

@bradmartin
Copy link

Working on adding this, android/java are not my specialites so I'm having a time including a forked repo into my project. If I knew the correct way to create a .jar file for this library then I could figure it out but for some reason my .jar files I generate aren't working correctly.

@TeeRawk
Copy link

TeeRawk commented Mar 14, 2017

Hello @bradmartin ,so does this worked for you ?

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

4 participants