Crashes when selecting wallpaper layers. #2

Closed
Dahie opened this Issue Feb 24, 2012 · 13 comments

2 participants

@Dahie

I ran the wallpaper from eclipse and installed on my device. When I select a set of wallpaper layers via custon_path. It stays black with this catlog message:

02-24 11:05:29.884: E/InputQueue-JNI(28174): channel '41cc9870 uk.co.halfninja.wallpaper.parallax.ParallaxWallpaper (client)' ~ Publisher closed input channel or an error occurred.  events=0x8

When I go back to the settings now, it crashes with this trace:

02-24 11:07:24.454: E/AndroidRuntime(28174): java.lang.OutOfMemoryError
02-24 11:07:24.454: E/AndroidRuntime(28174):    at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
02-24 11:07:24.454: E/AndroidRuntime(28174):    at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:493)
02-24 11:07:24.454: E/AndroidRuntime(28174):    at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:299)
02-24 11:07:24.454: E/AndroidRuntime(28174):    at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:324)
02-24 11:07:24.454: E/AndroidRuntime(28174):    at uk.co.halfninja.wallpaper.parallax.ParallaxWallpaper$ParallaxEngine.addLayer(ParallaxWallpaper.java:183)
02-24 11:07:24.454: E/AndroidRuntime(28174):    at uk.co.halfninja.wallpaper.parallax.ParallaxWallpaper$ParallaxEngine.loadLayers(ParallaxWallpaper.java:172)
02-24 11:07:24.454: E/AndroidRuntime(28174):    at uk.co.halfninja.wallpaper.parallax.ParallaxWallpaper$ParallaxEngine.onSharedPreferenceChanged(ParallaxWallpaper.java:155)
02-24 11:07:24.454: E/AndroidRuntime(28174):    at uk.co.halfninja.wallpaper.parallax.ParallaxWallpaper$ParallaxEngine.onCreate(ParallaxWallpaper.java:165)
02-24 11:07:24.454: E/AndroidRuntime(28174):    at android.service.wallpaper.WallpaperService$Engine.attach(WallpaperService.java:729)
02-24 11:07:24.454: E/AndroidRuntime(28174):    at android.service.wallpaper.WallpaperService$IWallpaperEngineWrapper.executeMessage(WallpaperService.java:973)
02-24 11:07:24.454: E/AndroidRuntime(28174):    at com.android.internal.os.HandlerCaller$MyHandler.handleMessage(HandlerCaller.java:61)
02-24 11:07:24.454: E/AndroidRuntime(28174):    at android.os.Handler.dispatchMessage(Handler.java:99)
02-24 11:07:24.454: E/AndroidRuntime(28174):    at android.os.Looper.loop(Looper.java:137)
02-24 11:07:24.454: E/AndroidRuntime(28174):    at android.app.ActivityThread.main(ActivityThread.java:4340)
02-24 11:07:24.454: E/AndroidRuntime(28174):    at java.lang.reflect.Method.invokeNative(Native Method)
02-24 11:07:24.454: E/AndroidRuntime(28174):    at java.lang.reflect.Method.invoke(Method.java:511)
02-24 11:07:24.454: E/AndroidRuntime(28174):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
02-24 11:07:24.454: E/AndroidRuntime(28174):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
02-24 11:07:24.454: E/AndroidRuntime(28174):    at dalvik.system.NativeStart.main(Native Method)

Thanks for the wallpaper, exactly what I'm looking for. :)

@halfninja
Owner

Hi! Didn't expect anyone else to be bothering with my project :)

Looks like it's running out of memory loading the wallpaper preview. Could you let me know what device you have, and the file size and format of the image layers you're using? Just to give me an idea of the amount of memory being taken up. I think Bitmaps are uncompressed so there may not be much I can do about loading more images than the phone can keep in memory, other than catch the exception and show a friendly error message.

Possibly if I move the rendering to OpenGL then it could use compressed textures.

Does the actual wallpaper fail too?

@halfninja
Owner

Could you also give it a go with some smaller, fewer images? Just to check that it's the memory problem and not also other things. The library should scale them up to fit the height of the screen so you can just downscale some existing images.

@Dahie

4xPng: 2.5mb, 2.6mb, 0.8mb and 0.9mb

if I scale them by 1/3 each to 1mb size, it works.

(but so far it only shows the first background, no additional layers.)

@halfninja
Owner

Another thing that I should document better - layer 1 is at the front, so possibly if your background is layer 1 then you need to reverse the order.

Okay, so it needs to handle memory better. What phone do you have?

@halfninja
Owner

Also if your background layer is saved as 32-bit, you could save it as 24-bit (without alpha) or even a JPEG to save a bit of space and memory.

@Dahie

Uhm, yes that is important. :)

Thanks! It works with 4 layers now, although the parallex-effect is quite weak. Is there a way to scale the offsets?

@halfninja
Owner

Thanks for testing it though, otherwise I'd miss this kind of obvious stuff!

Another thing that could be documented better... The scrolling is set such that you see the left hand of all images when scrolled to the left, and the right hand of all images if scrolled to the right. As such, if all the images are the same width they will move at the same speed. Try making the background layers narrower, or use a wider foreground layer. You can even use a foreground layer so wide that it moves faster than your app icons, if you want.

@Dahie

Ah, thank you!

This will get me started. Much appreciated and good timing with your live background. I only started looking for it yesterday. :)

You can close this issue. I guess.

@halfninja
Owner

I'll keep it open because I'd still like to handle the out of memory situation better - it could at least pop up a little toast.

@Dahie

Hm, yeah I just changed the widths and it easily breaks again with OutOfMemory. For the record, I'm testing on a Samsung Galaxy Nexus with Android 4.03

@halfninja
Owner

Okay, your phone is better than mine so I'd have thought it'd handle more! Though your screen is 1280px high compared to the 800px of the Desire which I have, so if you're using full height images then that might balance it out.

OpenGL and compressed textures is probably the way to make it work better in the long term.

@Dahie

Before finding your project, I stumbled upon this: http://code.google.com/p/libgdx-backend-android-livewallpaper/wiki/ExampleProject
I don't know how difficult to integrate this is for OpenGL-support. All I can say, it would be great, because while the wallpaper works and is reasonable fluent, it's not as fluent as can be and there is room for improvement. :)

@halfninja
Owner

Cool stuff - I haven't seen LibGDX before. I've done a tiny bit of OpenGL on Android before so I might be alright to implement it myself (there's no 3D after all, just a few textured rectangles). LibGDX also seems to use native libraries and might bulk up the size of the app quite a bit, so I'll see if I can get it going with just Java.

@halfninja halfninja was assigned Feb 24, 2012
@halfninja halfninja closed this Feb 24, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment