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

Unexpected stop on the demo #13

Open
Fischer-L opened this issue Sep 12, 2014 · 7 comments
Open

Unexpected stop on the demo #13

Fischer-L opened this issue Sep 12, 2014 · 7 comments

Comments

@Fischer-L
Copy link

Hi,
First of all, thank you for the great job on this.
I am trying it out thru the demo app in this project.

However, eveytime when I apply an effect then the demo app stops unexpectedly.

Here are some examples of what I got when the unexpected stop happens:

  1. Select the LOMO effect in the items menu to apply the LOMO effect. The code goes all the way to the line:47 in cn.Ragnarok.LomoFilter.changeToLomo, which calls NativeFilterFunc.lomoAddBlckRound to get int[] resultPixels. Then, suddenly the demo app stops to cease. The logcat outputs 2 msg:
  • E/dalvikvm(31965): VM aborting
  • A/libc(31965): Fatal signal 6 (SIGABRT) at 0x00007cdd (code=-6), thread 31965 (imagefilterdemo)
  1. This time, try the Relief effect. The code goes untill the line:24 in cn.Ragnarok.ReliefFilter.changeToRelief, which calls Bitmap.createBitmap to get Bitmap returnBitmap. The logcat outputs:
  • E/AndroidRuntime(324): FATAL EXCEPTION: main
  • E/AndroidRuntime(324): Process: com.example.androidimagefilterdemo, PID: 324
  • E/AndroidRuntime(324): java.lang.OutOfMemoryError
  • E/AndroidRuntime(324): at android.graphics.Bitmap.nativeCreate(Native Method)
  • E/AndroidRuntime(324): at android.graphics.Bitmap.createBitmap(Bitmap.java:882)
  • E/AndroidRuntime(324): at android.graphics.Bitmap.createBitmap(Bitmap.java:906)
  • E/AndroidRuntime(324): at cn.Ragnarok.ReliefFilter.changeToRelief(ReliefFilter.java:24)
  • E/AndroidRuntime(324): at cn.Ragnarok.BitmapFilter.changeStyle(BitmapFilter.java:42)
  • E/AndroidRuntime(324): at com.example.androidimagefilterdemo.MainActivity.applyStyle(MainActivity.java:322)
  • E/AndroidRuntime(324): at com.example.androidimagefilterdemo.MainActivity.onItemClick(MainActivity.java:266)
  • E/AndroidRuntime(324): at android.widget.AdapterView.performItemClick(AdapterView.java:299)
  • E/AndroidRuntime(324): at android.widget.AbsListView.performItemClick(AbsListView.java:1113)
  • E/AndroidRuntime(324): at android.widget.AbsListView$PerformClick.run(AbsListView.java:2904)
  • E/AndroidRuntime(324): at android.widget.AbsListView$3.run(AbsListView.java:3638)
  • E/AndroidRuntime(324): at android.os.Handler.handleCallback(Handler.java:733)
  • E/AndroidRuntime(324): at android.os.Handler.dispatchMessage(Handler.java:95)
  • E/AndroidRuntime(324): at android.os.Looper.loop(Looper.java:212)
  • E/AndroidRuntime(324): at android.app.ActivityThread.main(ActivityThread.java:5151)
  • E/AndroidRuntime(324): at java.lang.reflect.Method.invokeNative(Native Method)
  • E/AndroidRuntime(324): at java.lang.reflect.Method.invoke(Method.java:515)
  • E/AndroidRuntime(324): at com.android.internal.os.ZygoteInit$MinvitigethodAndArgsCaller.run(ZygoteInit.java:878)
  • E/AndroidRuntime(324): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
  • E/AndroidRuntime(324): at dalvik.system.NativeStart.main(Native Method)

Could the memory cause this issue ?
What could the root cause ?

Thank you

@ragnraok
Copy link
Owner

Hi, could you tell me what's device and system you are using?

@Fischer-L
Copy link
Author

Hi, Zony ZL with Android 4.4.2 and built with the 64bit, 20140702 version Eclipse ADT Bundle plus the android-ndk64-r10b.

@ragnraok
Copy link
Owner

It's Sony? It throw OutOfMemoryError, I think your machine doesn't have enough memory when you apply the filter

@Fischer-L
Copy link
Author

However, the device has 2G memory and when testing, it still has 1G free memory to use. Could there be other reason for the unexpected stop ?

@ragnraok
Copy link
Owner

may be the size of picture is too large, what's the picture resolution when you get crash?

@Fischer-L
Copy link
Author

The picture is 3920 x 2940, 2.54MB, taken by the device's camera. I think the problem lie on the picture's resolution like you says. Everything goes fine when using a small image, 800 x 800, 177KB.

@mhsabur
Copy link

mhsabur commented Sep 23, 2017

Android loads a bitmap as inMutable which means (briefly) it allows you to modify the bitmap in the RAM. But this consumes a lot of RAM. If you don't need to modify the image on the fly, you can turn this feature off while loading the image. This eliminates the out of memory exception. Check out the code below:

BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inMutable=false;
opts.inPurgeable=true; // may be deprecated depending on your configuration
Bitmap bm=null;
bm = BitmapFactory.decodeResource(cx.getResources(),
BitmapResId, opts); // BitmapResId is an integer resource id. eg: R.Drawable.myimage

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

3 participants