How can I get any details of my app crash?

Hello,

I have been developing an app for some months and I had never experienced a crash until today.

I am using the recommended pattern of having one only Screen, then simulating 4 screens by showing/hidding 4 HorizontalArrangements conveniently. I do not think my code is too large… in any case, I did not extend it today.

The only change I made today was a reorganization of some inner VerticalArrangements and HorizontalArrangements.

The question is: how can I get some clue that allows me to progress in the investigation towards a solution? Unfortunately, at this moment, all I can see is the companion immediately closing when I try to launch it (I mean, after the 30 seconds it takes to load the resource files).

Any way to get debug info, in order to check if some Java exception occurs, etc.?

Thank you for your help
David


Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

I appreciate your help, Taifun!

I will try everything before restoring a backup. The point is that I suspect that my issue is caused by some eventual corruption of the AIA. My app was just working fine before I dragged some arrangements using the GUI. Now I cannot even try to debug a part of the blocks, because the companion crashes even with the Screen1.Initialize empty :frowning:

Best regards,
David

please provide a logcat output as described earlier
thank you
Taifun

Hi Taifun, I am attaching the logcat output below.

After multiple tests, I have reached the situation where I can reproduce the error systematically: if I add one more VerticalArrangement, the app crashes; and if I delete it, the app works correctly again.

My app has quite a few VerticalArrangement and HorizontalArrangement, maybe 30-40 in total, spread across different ‘simulated’ screens that I make visible / invisible (following the recommendation to use a single Screen). I imagine that it is quite common in any app.


04-22 07:14:15.972 29567 29567 E Bitmap : width and height must be > 0, width=32, height=48
04-22 07:14:15.974 29567 29567 E AndroidRuntime: FATAL EXCEPTION: main
04-22 07:14:15.974 29567 29567 E AndroidRuntime: Process: edu.mit.appinventor.aicompanion3, PID: 29567
04-22 07:14:15.974 29567 29567 E AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method ‘boolean android.graphics.Bitmap.isMutable()’ on a null object reference
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at com.google.appinventor.components.runtime.Canvas$CanvasView.onSizeChanged(Canvas.java:468)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.view.View.sizeChange(View.java:19914)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.view.View.setFrame(View.java:19875)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.view.View.layout(View.java:19778)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1816)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1660)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.widget.LinearLayout.onLayout(LinearLayout.java:1569)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.view.View.layout(View.java:19781)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:6144)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.widget.FrameLayout.layoutChildren(FrameLayout.java:325)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.view.View.layout(View.java:19781)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:6144)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1816)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.widget.LinearLayout.layoutHorizontal(LinearLayout.java:1805)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.widget.LinearLayout.onLayout(LinearLayout.java:1571)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.view.View.layout(View.java:19781)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:6144)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.widget.FrameLayout.layoutChildren(FrameLayout.java:325)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.view.View.layout(View.java:19781)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:6144)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1816)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1660)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.widget.LinearLayout.onLayout(LinearLayout.java:1569)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.view.View.layout(View.java:19781)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:6144)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.widget.FrameLayout.layoutChildren(FrameLayout.java:325)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.view.View.layout(View.java:19781)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:6144)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at com.google.appinventor.components.runtime.ScaledFrameLayout.onLayout(ScaledFrameLayout.java:193)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.view.View.layout(View.java:19781)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:6144)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1816)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1660)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.widget.LinearLayout.onLayout(LinearLayout.java:1569)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.view.View.layout(View.java:19781)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:6144)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.widget.FrameLayout.layoutChildren(FrameLayout.java:325)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.view.View.layout(View.java:19781)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:6144)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.support.v7.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:444)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.view.View.layout(View.java:19781)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:6144)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.widget.FrameLayout.layoutChildren(FrameLayout.java:325)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.view.View.layout(View.java:19781)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:6144)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1816)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1660)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.widget.LinearLayout.onLayout(LinearLayout.java:1569)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.view.View.layout(View.java:19781)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:6144)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.widget.FrameLayout.layoutChildren(FrameLayout.java:325)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at com.android.internal.policy.DecorView.onLayout(DecorView.java:888)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.view.View.layout(View.java:19781)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:6144)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2674)
04-22 07:14:15.974 29567 29567 E AndroidRuntime: at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2377)
04-22 07:14:15.975 29567 29567 E AndroidRuntime: at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1515)
04-22 07:14:15.975 29567 29567 E AndroidRuntime: at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7266)
04-22 07:14:15.975 29567 29567 E AndroidRuntime: at android.view.Choreographer$CallbackRecord.run(Choreographer.java:981)
04-22 07:14:15.975 29567 29567 E AndroidRuntime: at android.view.Choreographer.doCallbacks(Choreographer.java:790)
04-22 07:14:15.975 29567 29567 E AndroidRuntime: at android.view.Choreographer.doFrame(Choreographer.java:721)
04-22 07:14:15.975 29567 29567 E AndroidRuntime: at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:967)
04-22 07:14:15.975 29567 29567 E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:808)
04-22 07:14:15.975 29567 29567 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:101)
04-22 07:14:15.975 29567 29567 E AndroidRuntime: at android.os.Looper.loop(Looper.java:166)
04-22 07:14:15.975 29567 29567 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:7523)
04-22 07:14:15.975 29567 29567 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
04-22 07:14:15.975 29567 29567 E AndroidRuntime: at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
04-22 07:14:15.975 29567 29567 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)

I also wanted to comment that I have disabled the Screen1.Initialize block. Nor do I have any Timer enabled. In short, my app is doing nothing more than rendering the graphical interface in the initial state.

Thanks

Have you tried setting all those arrangements Visible=false to reduce size calculation complexity at startup time?

it seems to be, you reached a point, where only one screen will not help anymore for your requirements... 30-40 arrangements in one screens seem to be too much... therefore let me suggest you to split the screen into 2 screens and have 20 virtual screens in screen1 and another 20 virtual screens in screen2...

these links might help to copy the screen

Taifun

Thank you, I will try your suggestions.

In fact, my app only has 4 virtual screens. The rest, are inner Vertical and Horizontal arrangements to help distribute the labels and textboxes properly on the right location (centered, etc.).

At any moment, there is only one virtual screen visible and the other three are invisible. I do not explicitly set visible=false for the inner arrangements, labels or textboxes as it is not needed, but I will give it a try just in case it can save processing effort.

Hello, I managed to reduce the number of arrangements to only 17 and I still can reproduce the crash of the companion app.

Could someone test the Crash8.aia file to confirm that it also crashes in their environment please? If this is the case, I would like to propose it as a bug.

Thank you very much.
David

Crash8
Crash8.aia (1.7 KB)

What does "crash" mean here? Which error is displayed.
Does this happen with Companion and / or the APK?
The aia opens with no issues (Companion) (but there are no blocks).

Hi Anke, thank you for your time. I removed all the blocks and resources (image files) to demonstrate that they were not the cause of the problem.

In my environment, the companion app closes immediately, without displaying any message on screen. Please see the log of the exception in my previous post (I obtained it using the adb tool).

Could you confirm if you can launch the companion succesfully in your environment?

Thanks
David

Hi @davidjava,

Do you have the same issue if you create a fresh project with just a Canvas?

A deeper inspection of your stack trace from adb logcat indicates that a null object is being referenced, but according to the Android documentation the call that sets that value should never return null. What version of Android are you running, and on what device?

Yes, win 7, Firefox / Chrome, Galaxy Note8, Android 9.

No crash on the stock AI2 emulator/companion, Win7 Brave.

I am experiencing the crash of the companion on a Huawei P8 running Android 8.0. My laptop runs Windows 10, Chrome.

Thank you for your feedback. I will try to provide more details… no more hints at the moment.

Perhaps it worths to comment that everything works fine until the moment I add the 17th arrangement. I mean, if I delete one of the arrangements, the issue disappears and everything works fine (with 16 horizontal/vertical arrangements). But if I add it again, it starts to crash again.

In the adb logs, do you see anything about memory issues before the null pointer exception? I could imagine that it might be failing to allocate memory for the scaled bitmap and returning null instead of throwing an OutOfMemoryError (although the latter would make more sense).

@ewpatton, I have checked the logs thoroughly but I have not found any other error log related to the app, nor any other log in general related to memory issues.

However, I have somehow managed to “fix” the json of the graphical interface, after a trial and error process that took me a few hours. By simply rearranging the arrangements, I manage to avoid the crash!

IMHO, my intuition after 25 years programming in java tells me that there must be a bug. But I would need the help of someone skilled in the field to finish finding it.

Please examine the files in the order I have uploaded them: The Screen1.scm.works-fine1.json file is processed correctly. But if I move either of the two components VerticalArrangement8 or VerticalArrangement9 just before VirtualScreen1, the crash occurs (Screen1.scm.causes-to-crash1.json and Screen1.scm.causes-to-crash2.json). However, if I move the VerticalArrangement8 and VerticalArrangement9 components right after Menu, it is processed correctly again (Screen1.scm.works-fine2.json).

I cannot understand why, but I have observed two things that have surprised me:

  • Some Uuids have a negative number
  • Some arrangements are missing Height, Width, or both elements

Regards,
David

Screen1.scm.works-fine1.json (8.4 KB)
Screen1.scm.causes-to-crash1.json (8.4 KB)
Screen1.scm.causes-to-crash2.json (8.4 KB)
Screen1.scm.works-fine2.json (8.4 KB)

UUID here is a bit of a misnomer that's carried through App Inventor over the years. It's just a unique identifier, not a true UUID. The UUID in App Inventor is just a 32 bit signed integer.

We only store values for properties if they differ from the defaults, so if you don't see a Width or Height value, the value is usually "Automatic" by default.


If you could dump the whole adb logcat from launching the companion through the crash, that might give us some additional information to look at w.r.t. the crash.