I have multiple strange crash reports via Firebase Crashlytics during last week from different devices. They are:
Stack traces are identical and doesn't include any reference to my code, so I dont know where crash happen and why. Searching for my exception gives nothing. So I hope somebody can help me investigating that crashes. As I understand, crash happen somewhere inside ConstraintLayout library (I use version 1.1.3).
Crash stack trace:
Fatal Exception: java.lang.StackOverflowError
at java.util.HashMap$KeySet.<init>(HashMap.java:911)
at java.util.HashMap$KeySet.<init>(HashMap.java:911)
at java.util.HashMap.keySet(HashMap.java:696)
at java.util.HashSet.iterator(HashSet.java:161)
at android.support.constraint.solver.widgets.ResolutionNode.didResolve(ResolutionNode.java:70)
at android.support.constraint.solver.widgets.ResolutionAnchor.resolve(ResolutionAnchor.java:140)
at android.support.constraint.solver.widgets.ResolutionNode.didResolve(ResolutionNode.java:71)
at android.support.constraint.solver.widgets.ResolutionAnchor.resolve(ResolutionAnchor.java:140)
----A lot of identical lines----
at android.support.constraint.solver.widgets.ResolutionNode.didResolve(ResolutionNode.java:71)
at android.support.constraint.solver.widgets.ResolutionAnchor.resolve(ResolutionAnchor.java:85)
at android.support.constraint.solver.widgets.ConstraintWidgetContainer.solveGraph(ConstraintWidgetContainer.java:586)
at android.support.constraint.solver.widgets.ConstraintWidgetContainer.optimize(ConstraintWidgetContainer.java:643)
at android.support.constraint.solver.widgets.ConstraintWidgetContainer.layout(ConstraintWidgetContainer.java:328)
at android.support.constraint.ConstraintLayout.solveLinearSystem(ConstraintLayout.java:1860)
at android.support.constraint.ConstraintLayout.onMeasure(ConstraintLayout.java:1621)
at android.view.View.measure(View.java:16749)
at android.widget.ScrollView.measureChildWithMargins(ScrollView.java:1235)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at android.widget.ScrollView.onMeasure(ScrollView.java:327)
at android.view.View.measure(View.java:16749)
at android.support.constraint.ConstraintLayout.internalMeasureChildren(ConstraintLayout.java:1227)
at android.support.constraint.ConstraintLayout.onMeasure(ConstraintLayout.java:1572)
at android.view.View.measure(View.java:16749)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5295)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:143)
at android.view.View.measure(View.java:16749)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5295)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1413)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:696)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:589)
at android.view.View.measure(View.java:16749)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5295)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at android.view.View.measure(View.java:16749)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5295)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1413)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:696)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:589)
at android.view.View.measure(View.java:16749)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5295)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2439)
at android.view.View.measure(View.java:16749)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2072)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1175)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1372)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1062)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5996)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
at android.view.Choreographer.doCallbacks(Choreographer.java:574)
at android.view.Choreographer.doFrame(Choreographer.java:544)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5590)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
at dalvik.system.NativeStart.main(NativeStart.java)
Please help me to find out the reason of that crash or at least how to reproduce it.
UPD:
With help of my users I found out a place, where crash happens. It's an activity, where layout is not inflated from xml but generated in onCreate() by code (ConstraintLayout as root).
A ConstraintLayout is a ViewGroup which allows you to position and size widgets in a flexible way. Note: ConstraintLayout is available as a support library that you can use on Android systems starting with API level 9 (Gingerbread). As such, we are planning on enriching its API and capabilities over time.
Advantages of using ConstraintLayout in Android It helps to improve the UI performance over other layouts. With the help of ConstraintLayout, we can control the group of widgets through a single line of code. With the help of ConstraintLayout, we can easily add animations to the UI components which we used in our app.
Bias, in terms of ConstraintLayout , means "if there is extra room, slide the widget in this direction along the axis". The default bias is 0.5, meaning that the widget is centered in the available space.
Finally I found out what was the reason.
I have an activity, where some number of Views were added dynamically depending on list with data passed to activity and type of every item. They were added to ConstraintLayout inside ScrollView. Crash happen when number of added views exceed ~30.
Solution: I switched to RecyclerView to do more effective drawing and optimize memory usage and problem gone. Do not repeat my mistake and use RecyclerView to display large lists. Main mistake was that I could not imagine case, where that list will be really large but here we are.
That does not explain why crash happen only on Samsung devices and only on Android 4.2-4.4, but anyway it is better solution to use RecyclerView.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With