Android: Preview Image OutOfMemoryError

Created on 19 Apr 2017  路  6Comments  路  Source: nextcloud/android

Actual behaviour

After open many times PreviewImageActivity the App is crashing

Steps to reproduce

  1. Open the App
  2. Select a Image
  3. Open Image Detail
  4. Open Participate Section
  5. Open All Files
  6. Repeat step "2" three or four times

Environment data

Android version: 7.1.2

Device model: Nexus 5X

Stock or customized system:

Nextcloud app version: Master

Nextcloud server version: 11

Logs

ezgif com-video-to-gif

bug

All 6 comments

I tried to reproduce, do I have to repeat steps 2 - 5 for 2-3 times?
It did not crashed on my nougat emulator.
Do you have a logcat?

@tobiasKaminsky yes You have to repeat steps 2-5 for many times it depends of images weight

I send you the logcat

04-19 11:13:36.351 27838-27838/com.nextcloud.client E/AndroidRuntime: FATAL EXCEPTION: main Process: com.nextcloud.client, PID: 27838 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.nextcloud.client/com.owncloud.android.ui.activity.FileDisplayActivity}: android.view.InflateException: Binary XML file line #34: Binary XML file line #38: Error inflating class <unknown> at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2666) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2727) at android.app.ActivityThread.-wrap12(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1478) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6121) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779) Caused by: android.view.InflateException: Binary XML file line #34: Binary XML file line #38: Error inflating class <unknown> Caused by: android.view.InflateException: Binary XML file line #38: Error inflating class <unknown> Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Constructor.newInstance0(Native Method) at java.lang.reflect.Constructor.newInstance(Constructor.java:430) at android.view.LayoutInflater.createView(LayoutInflater.java:645) at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58) at android.view.LayoutInflater.onCreateView(LayoutInflater.java:717) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:785) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727) at android.view.LayoutInflater.rInflate(LayoutInflater.java:858) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821) at android.view.LayoutInflater.parseInclude(LayoutInflater.java:994) at android.view.LayoutInflater.rInflate(LayoutInflater.java:854) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821) at android.view.LayoutInflater.rInflate(LayoutInflater.java:861) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821) at android.view.LayoutInflater.inflate(LayoutInflater.java:518) at android.view.LayoutInflater.inflate(LayoutInflater.java:426) at android.view.LayoutInflater.inflate(LayoutInflater.java:377) at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284) at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:143) at com.owncloud.android.ui.activity.FileDisplayActivity.onCreate(FileDisplayActivity.java:190) at android.app.Activity.performCreate(Activity.java:6682) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2619) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2727) at android.app.ActivityThread.-wrap12(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1478) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6121) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779) Caused by: java.lang.OutOfMemoryError: Failed to allocate a 57288 byte allocation with 46848 free bytes and 45KB until OOM at dalvik.system.VMRuntime.newNonMovableArray(Native Method) at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method) at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:620) at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:455) at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:1155) 04-19 11:13:36.352 27838-27838/com.nextcloud.client E/AndroidRuntime: at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:720) at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:571) at android.content.res.Resources.loadDrawable(Resources.java:858) at android.content.res.TypedArray.getDrawable(TypedArray.java:928) at android.graphics.drawable.AnimationDrawable.inflateChildElements(AnimationDrawable.java:327) at android.graphics.drawable.AnimationDrawable.inflate(AnimationDrawable.java:297) at android.graphics.drawable.DrawableInflater.inflateFromXml(DrawableInflater.java:130) at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1227) at android.graphics.drawable.Drawable.createFromXml(Drawable.java:1200) at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:715) at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:571) at android.content.res.Resources.loadDrawable(Resources.java:858) at android.content.res.TypedArray.getDrawable(TypedArray.java:928) at android.widget.ProgressBar.<init>(ProgressBar.java:319) at android.widget.ProgressBar.<init>(ProgressBar.java:269) at android.widget.ProgressBar.<init>(ProgressBar.java:265) ... 32 more

I have found another way to trigger it:

  • open a big image
  • open file detail
  • click on back
  • do those steps over and over
    In Android Studio -> android monitor -> monitors you can see the allocated memory growing. For me it crashes with > 350Mb.

Also if you have done the above steps several times and then click "back" you will see the old preview activities.

I can fix it, but i don't know what is the expected behavior when the user is on detail and click back

Would really be great, if you can help us with that 馃憤

I think he should see the related picture again, so it would be:
all files
picture
detail view
picture
all files

And pressing back on "all files" should suspend the app (like it it now doing right after a fresh start)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AndyScherzinger picture AndyScherzinger  路  3Comments

toobie83 picture toobie83  路  3Comments

tobiasKaminsky picture tobiasKaminsky  路  3Comments

ThaDaVos picture ThaDaVos  路  3Comments

ikke-t picture ikke-t  路  3Comments