Texture size crash on Android 4.2.1 (Nexus4)

Started by Raswr, February 06, 2013, 02:18:03 PM

Previous topic - Next topic

Raswr

Hi!

I recently switched to a Nexus 4 phone with Android 4.2.1 and i'm getting some weird crashes while loading textures. All my textures are square of 2 size, but I'm getting errors like these when executing Texture aux=new Texture(res.getDrawable(id),alpha); and after that activity stops

256x256 size texture:

02-06 14:05:26.487: I/jPCT-AE(17562): Loading Texture...
02-06 14:05:26.487: I/jPCT-AE(17562): [ 1360155926496 ] - ERROR: Unsupported Texture width: 341
02-06 14:05:26.487: I/jPCT-AE(17562): [ 1360155926500 ] - ERROR: java.lang.RuntimeException: [ 1360155926496 ] - ERROR: Unsupported Texture width: 341
02-06 14:05:26.487: I/jPCT-AE(17562): at com.threed.jpct.Logger.log(Logger.java:189)
02-06 14:05:26.487: I/jPCT-AE(17562): at com.threed.jpct.Texture.loadTexture(Texture.java:798)
02-06 14:05:26.487: I/jPCT-AE(17562): at com.threed.jpct.Texture.<init>(Texture.java:198)
02-06 14:05:26.487: I/jPCT-AE(17562): at com.threed.jpct.Texture.<init>(Texture.java:234)


128x128 texture:

02-06 14:09:46.624: I/jPCT-AE(18345): [ 1360156186637 ] - ERROR: Unsupported Texture width: 171
02-06 14:09:46.624: I/jPCT-AE(18345): [ 1360156186639 ] - ERROR: java.lang.RuntimeException: [ 1360156186637 ] - ERROR: Unsupported Texture width: 171
02-06 14:09:46.624: I/jPCT-AE(18345): at com.threed.jpct.Logger.log(Logger.java:189)
02-06 14:09:46.624: I/jPCT-AE(18345): at com.threed.jpct.Texture.loadTexture(Texture.java:798)
02-06 14:09:46.624: I/jPCT-AE(18345): at com.threed.jpct.Texture.<init>(Texture.java:198)
02-06 14:09:46.624: I/jPCT-AE(18345): at com.threed.jpct.Texture.<init>(Texture.java:234)


Some more info that appears on my logcat

02-06 14:15:53.186: I/jPCT-AE(18762): GL20 render pipeline initialized!
02-06 14:15:53.186: I/jPCT-AE(18762): OpenGL vendor:     Qualcomm
02-06 14:15:53.186: I/jPCT-AE(18762): OpenGL renderer:   Adreno (TM) 320
02-06 14:15:53.186: I/jPCT-AE(18762): OpenGL version:    OpenGL ES 2.0 V@6.0 AU@ (CL@2946718)
02-06 14:15:53.186: I/jPCT-AE(18762): OpenGL renderer initialized (using 2 texture stages)



Last time I tested my app on my Samsung Galaxy S plus it worked fine, now a relative has that phone so i can't test it again in it until tonight! Any ideas?

Thanks :)

EgonOlsen

Don't use drawable to store your textures. Use either raw or the assets directory. Images in drawable can get scaled at load time by Android, which is what happens here.

Raswr

#2
Quote from: EgonOlsen on February 06, 2013, 06:51:03 PM
Don't use drawable to store your textures. Use either raw or the assets directory. Images in drawable can get scaled at load time by Android, which is what happens here.

Wow! how didn't I know that? It never happened to me on my other phone, now I'm sure this one is upscaling the images as it has higher resolution, makes sense. Time for me to fix that, thanks :) (and sorry, this  was quite unrelated to jpct-ae)

kelmer

Depending on which folder you stored your texture, it might be upscaled or downscaled, again depending on target device. If you stored it in the drawable folder, then for medium density devices (which is the baseline for android) it won't be rescaled. That's probably the reason it worked on your Galaxy S but not on your nexus 4 (which would have a higher density)