openreads icon indicating copy to clipboard operation
openreads copied to clipboard

[BUG] App crashes when adding book (OutOfMemoryError)

Open Arnvidr opened this issue 3 years ago • 2 comments

When the book list grows, adding books crashes the app more and more frequently. At first, it crashed after adding books, when trying to go back to the list screen. After a point, this crash happened after every book added, until the point where the app now crashes when selecting a result from the search screen (searching Open Library).

  • Manufacturer and model: Sony Xperia 10 II
  • Android version: 12
  • App version: 1.15.0
  • App source (F-Droid, Google Play, Github): F-Droid

Additional context Phone reports having more than 1GB free memory, and that this app uses very little of it, but the log shows an out of memory error, not sure how this works. Could there be a setting on the phone that limits this too much?

FATAL EXCEPTION: main
Process: software.mdev.bookstracker, PID: 29591
java.lang.OutOfMemoryError: Failed to allocate a 80 byte allocation with 531272 free bytes and 518KB until OOM, target footprint 134217728, growth limit 134217728; giving up on allocation because <1% of heap free after GC.
       at q.h.<init>(SolverVariable.java:7)
       at s.c.i(ConstraintAnchor.java:2)
       at s.d.H(ConstraintWidget.java:8)
       at s.j.H(WidgetContainer.java:4)
       at s.e.V(ConstraintWidgetContainer.java:316)
       at t.b.b(BasicMeasure.java:15)
       at androidx.constraintlayout.widget.ConstraintLayout.onMeasure(ConstraintLayout.java:217)
       at android.view.View.measure(View.java:25787)
       at androidx.constraintlayout.widget.ConstraintLayout$b.b(ConstraintLayout.java:74)
       at s.e.e0(ConstraintWidgetContainer.java:48)
       at t.h.b(Direct.java:5)
       at t.h.d(Direct.java:16)
       at t.h.b(Direct.java:30)
       at t.h.d(Direct.java:16)
       at t.h.b(Direct.java:30)
       at t.h.d(Direct.java:16)
       at t.h.b(Direct.java:30)
       at s.e.V(ConstraintWidgetContainer.java:50)
       at t.b.b(BasicMeasure.java:15)
       at androidx.constraintlayout.widget.ConstraintLayout.onMeasure(ConstraintLayout.java:217)
       at android.view.View.measure(View.java:25787)
       at android.widget.ScrollView.measureChildWithMargins(ScrollView.java:1441)
       at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
       at android.widget.ScrollView.onMeasure(ScrollView.java:458)
       at android.view.View.measure(View.java:25787)
       at androidx.constraintlayout.widget.ConstraintLayout$b.b(ConstraintLayout.java:74)
       at t.b.a(BasicMeasure.java:15)
       at androidx.constraintlayout.widget.ConstraintLayout.onMeasure(ConstraintLayout.java:190)
       at android.view.View.measure(View.java:25787)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6980)
       at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
       at android.view.View.measure(View.java:25787)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6980)
       at androidx.coordinatorlayout.widget.CoordinatorLayout.t(CoordinatorLayout.java:1)
       at s2.c.i(HeaderScrollingViewBehavior.java:14)
       at androidx.coordinatorlayout.widget.CoordinatorLayout.onMeasure(CoordinatorLayout.java:53)
       at android.view.View.measure(View.java:25787)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6980)
       at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
       at android.view.View.measure(View.java:25787)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6980)
       at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1552)
       at android.widget.LinearLayout.measureVertical(LinearLayout.java:842)
       at android.widget.LinearLayout.onMeasure(LinearLayout.java:721)
       at android.view.View.measure(View.java:25787)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6980)
       at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
       at com.android.internal.policy.DecorView.onMeasure(DecorView.java:778)
       at android.view.View.measure(View.java:25787)
       at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:3620)
       at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:2419)
       at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2689)
       at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2138)
       at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8686)
       at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1120)
       at android.view.Choreographer.doCallbacks(Choreographer.java:926)
       at android.view.Choreographer.doFrame(Choreographer.java:859)
       at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1105)
       at android.os.Handler.handleCallback(Handler.java:938)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loopOnce(Looper.java:346)
       at android.os.Looper.loop(Looper.java:475)
       at android.app.ActivityThread.main(ActivityThread.java:7889)
       at java.lang.reflect.Method.invoke(Native Method)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1009)

Arnvidr avatar Jun 26 '22 15:06 Arnvidr

It occurs to me that the above stacktrace shows no code paths belonging to openreads, so I went back to the logs, this time on the new version 1.16.0. Here is the latest error in the log after clicking the add icon in the For Later tab, where I have a long list, selecting Search in Open Library, making a search, and selecting a result.

FATAL EXCEPTION: main
Process: software.mdev.bookstracker, PID: 7892
android.view.InflateException: Binary XML file line #46 in software.mdev.bookstracker:layout/dialog_add_edit_book: Binary XML file line #46 in software.mdev.bookstracker:layout/dialog_add_edit_book: Error inflating class com.google.android.material.textfield.TextInputLayout
Caused by: android.view.InflateException: Binary XML file line #46 in software.mdev.bookstracker:layout/dialog_add_edit_book: Error inflating class com.google.android.material.textfield.TextInputLayout
Caused by: java.lang.reflect.InvocationTargetException
       at java.lang.reflect.Constructor.newInstance0(Native Method)
       at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
       at android.view.LayoutInflater.createView(LayoutInflater.java:858)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1010)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:965)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:1127)
       at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:1130)
       at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:1130)
       at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:1130)
       at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:1130)
       at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:686)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:538)
       at software.mdev.bookstracker.ui.bookslist.dialogs.AddEditBookDialog.onCreateView(AddEditBookDialog.kt:2)
       at androidx.fragment.app.Fragment.performCreateView(Fragment.java:4)
       at androidx.fragment.app.m.performCreateView(DialogFragment.java:1)
       at androidx.fragment.app.d0.f(FragmentStateManager.java:26)
       at androidx.fragment.app.d0.k(FragmentStateManager.java:27)
       at androidx.fragment.app.x.C(FragmentManager.java:122)
       at androidx.fragment.app.x.V(FragmentManager.java:10)
       at androidx.fragment.app.x.A(FragmentManager.java:14)
       at androidx.fragment.app.x$d.run(FragmentManager.java:1)
       at android.os.Handler.handleCallback(Handler.java:938)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loopOnce(Looper.java:346)
       at android.os.Looper.loop(Looper.java:475)
       at android.app.ActivityThread.main(ActivityThread.java:7889)
       at java.lang.reflect.Method.invoke(Native Method)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1009)
Caused by: android.view.InflateException: Binary XML file line #18 in software.mdev.bookstracker:layout/design_text_input_end_icon: Binary XML file line #18 in software.mdev.bookstracker:layout/design_text_input_end_icon: Error inflating class com.google.android.material.internal.CheckableImageButton
Caused by: android.view.InflateException: Binary XML file line #18 in software.mdev.bookstracker:layout/design_text_input_end_icon: Error inflating class com.google.android.material.internal.CheckableImageButton
Caused by: java.lang.ClassNotFoundException: com.google.android.material.internal.CheckableImageButton
       at java.lang.Class.classForName(Native Method)
       at java.lang.Class.forName(Class.java:454)
       at android.view.LayoutInflater.createView(LayoutInflater.java:819)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1010)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:965)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:663)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:538)
       at com.google.android.material.textfield.TextInputLayout.<init>(TextInputLayout.java:29)

...which, frankly, I'm also not able to read very well, although at least a few references to the app code shows up.

ArveMediaconnect avatar Jul 05 '22 19:07 ArveMediaconnect

Hello! I would like to say that the app crashes for me as well. It happends when I edit books and it happens more often now (I have added 64 books so far) than before. Everything that I added was manual and it includes book covers.

If I open the app now and I start adding/editing books than by the third one it will start slowing down and then it will crash.

I have a Xiaomi Mi A2 Lite with Android version 10 installed. I am using app version 1.16.0.

Apologies if the format in which I posted is not proper, I am not a developer and I'm not sure how to do this properly.

Do you need/should I provide more information?

edit: I have added now nearly 70 books and the app starts slowing down and then crashes by the time I'm done with the second book.

edit 2: Aaand now it's randomly crashing even when I sort through the books or checks the statistics. : /

brucetheelephant avatar Aug 31 '22 18:08 brucetheelephant

@Arnvidr @ArveMediaconnect @brucetheelephant please reopen if issues still occur after 2.0.0 release.

mateusz-bak avatar Mar 14 '23 10:03 mateusz-bak

@mateusz-bak Any idea if/when the f-droid build will be released? It seems to have failed on build with a timeout while flutter is doing its thing [1] but I have no idea if the app developer or the f-droid developer is the one that should be trying to figure out what goes wrong, or trigger a new build if something random happened. I see that you did the merge request [2] for the new flutter versions, but when the actual release 2.0.3 was built, this error happened.

[1] https://monitor.f-droid.org/builds/log/software.mdev.bookstracker/43 [2] https://gitlab.com/fdroid/fdroiddata/-/merge_requests/12734

Arnvidr avatar Mar 30 '23 10:03 Arnvidr

I reported the issue in F-Droid repository, will see what happens

mateusz-bak avatar Mar 31 '23 17:03 mateusz-bak