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

Getting NullPointerException onSurfaceCreated at launch on newer devices #1577

Closed
mukulabdagiri opened this issue Feb 18, 2016 · 12 comments
Closed

Comments

@mukulabdagiri
Copy link

Hi,

My live wallpaper app works on older devices which use Android KitKat. But newer devices such as Samsung Galaxy S6 which use Android Lollipop are throwing exception when launching the app. I am not sure if it is an Android OS issue here. I am using Rajawali-0.9 library. Following is the stack trace:

java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference
    at rajawali.e.j.a(Unknown Source)
    at rajawali.e.j.a(Unknown Source)
    at rajawali.e.j.a(Unknown Source)
    at rajawali.e.j.a(Unknown Source)
    at com.mycompany.livewallpaper.myapp.a.a(Unknown Source)
    at com.mycompany.livewallpaper.myapp.c.a(Unknown Source)
    at com.mycompany.livewallpaper.myapp.c.a(Unknown Source)
    at rajawali.i.c.onSurfaceCreated(Unknown Source)
    at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1539)
    at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1278)

Any idea what might be causing this error?

Thanks,
Mukul

@jwoolston
Copy link
Member

Without seeing an unobfuscated trace, its difficult to say.

@mukulabdagiri
Copy link
Author

It's not an obfuscated trace. Only thing I changed was "mycompany" and "myapp". Rest everything is as what I see in the trace.

@ToxicBakery
Copy link
Member

This is a crash from a proguard obfuscated application. Without reversing the obfuscation it would be difficult to understand the crash.

http://developer.android.com/tools/help/proguard.html

@mukulabdagiri
Copy link
Author

Right, obfuscation was due to Proguard. Below is the unobfuscated trace. It seems like the error occurs when I try to add ETC1 texture to plane.

My code where error takes place:

/*InputStream texture*/
planeMat = new SimpleMaterial();
planeMat.addTexture(mTextureManager.addEtc1Texture(texture, null, TextureType.DIFFUSE));
plane.setMaterial(planeMat);

Stack trace:

java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference
    at rajawali.materials.TextureManager.addTexture(TextureManager.java:210)
    at rajawali.materials.TextureManager.addTexture(TextureManager.java:191)
    at rajawali.materials.TextureManager.addTexture(TextureManager.java:188)
    at rajawali.materials.TextureManager.addEtc1Texture(TextureManager.java:425)
    at com.mycompany.android.livewallpaper.myapp.BackgroundImage.init(BackgroundImage.java:40)
    at com.mycompany.android.livewallpaper.myapp.Renderer.initImage(Renderer.java:149)
    at com.mycompany.android.livewallpaper.myapp.Renderer.initScene(Renderer.java:96)
    at rajawali.renderer.RajawaliRenderer.onSurfaceCreated(RajawaliRenderer.java:362)
    at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1539)
    at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1278)

@jwoolston
Copy link
Member

The log prior to the NPE should tell you that one of the following 3 cases happend:

  • An error log with the tag "addEtc1Texture" and an exception message from the ETC1 decoder failing
  • A debug log with the tag "ETC1" and message "Falling back to uncompressed texture", this would be due to a null texture being returned by the ETC1 decoder
  • A debug log with the tag "ETC1" and message "ETC1 texture load successful" for success.

Given the bug, I do not expect you will see the last one. Most likely what is happening is your ETC1 texture is corrupted or the stream is in some way failing, causing the decoder to fail.

@mukulabdagiri
Copy link
Author

I dont think the ETC1 texture is corrupted. It works fine on my devices (Samsung Galaxy S4, Note 10.1), but it apparently failed on LG G3 and Samsung Galaxy S6. I haven't tested on other devices. Is the ETC1 texture format not supported for these devices, but there is not much difference between SGS4 and SGS6.

@jwoolston
Copy link
Member

Samsung devices have a long history of behaving differently from device to device, though this is not a case I would expect them to. What log message do you see prior to the NPE?

@jwoolston
Copy link
Member

Closing this issue as stale. Please add the requested info if this is still a problem.

@mukulabdagiri
Copy link
Author

Apologies for late reply. The problem is still there. I had to purchase a device (Samsung GS6) which was throwing this error, to actually debug it, but to my surprise, it does not give me that error on my SGS6, but does fail on another SGS6 i received report from.
So I have to troubleshoot what might be causing the problem to avoid it.

The live wallpaper loads fine but when user tries to set wallpaper, it fails throwing the NPE. So i dont think the texture is corrupted. Does it have to do with memory? I am loading 42 PKM files each 1600x900 resolution. The target failing device is new and high end, so not low on memory.
Is there an alternative to PKM files which load fast with decent compression?

I am really sorry for not having a clear debug log because it does not fail on my test device which is apparently same model as the device on which it fails.

@jwoolston
Copy link
Member

does not fail on my test device which is apparently same model as the device on which it fails

Are you sure? Samsung devices are notorious for being the same model and having different hardware. You will need to compare the precise model number and look at the GPU/CPU combos.

I will re-open this issue but without being able to reproduce/see log info, it will be difficult to resolve. ETC2 is a similarly performant format with some other benefits that might be worth looking into, but it requires GL ES 3 or the appropriate extension (shouldnt be a problem on an S6).

Another thought occurred that you have proguard enabled on this app. In your local testing with the S6, have you tried the proguarded version? I have in the past had issues when allowing proguard to run on a library where it would remove things it thought weren't needed, causing NPEs. If the proguard version crashes and the debug version does not, then try disabling proguard on the org.rajawali3d.** package.

@jwoolston jwoolston reopened this Mar 24, 2016
@jwoolston
Copy link
Member

@mukulabdagiri I see you are using version 0.9....this is no longer supported, in large part due to the frequency of issues like this one. Your best bet for support using 0.9 is going to be the G+ community. If you want support from the developers, you will need to updated to a 1.x version.

@mukulabdagiri
Copy link
Author

I am using Rajawali-0.9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants