airsdk / Adobe-Runtime-Support

Report, track and discuss issues in Adobe AIR. Monitored by Adobe - and HARMAN - and maintained by the AIR community.
200 stars 11 forks source link

Crash: Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getVisibility()' on a null object reference #1606

Open Dima107 opened 2 years ago

Dima107 commented 2 years ago

AIR SDK 33.1.1.620 - 713 Android: Android 9 - 64% Android 8 - 35% Android 10 <1% I can't repicate this. It's log from Crashlytics I attached file with threads codes @marchbold I see code from you Firebase, Crashlitycs, GooglePlayServices, okhttp into threads. Can you look at this please?

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getVisibility()' on a null object reference at android.widget.FrameLayout.layoutChildren(FrameLayout.java:275) at android.widget.FrameLayout.onLayout(FrameLayout.java:261) at android.view.View.layout(View.java:20967) at android.view.ViewGroup.layout(ViewGroup.java:6440) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) at android.widget.FrameLayout.onLayout(FrameLayout.java:261) at android.view.View.layout(View.java:20967) at android.view.ViewGroup.layout(ViewGroup.java:6440) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1791) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1635) at android.widget.LinearLayout.onLayout(LinearLayout.java:1544) at android.view.View.layout(View.java:20967) at android.view.ViewGroup.layout(ViewGroup.java:6440) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) at android.widget.FrameLayout.onLayout(FrameLayout.java:261) at com.android.internal.policy.DecorView.onLayout(DecorView.java:955) at android.view.View.layout(View.java:20967) at android.view.ViewGroup.layout(ViewGroup.java:6440) at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:3092) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2779) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1863) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8072) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911) at android.view.Choreographer.doCallbacks(Choreographer.java:723) at android.view.Choreographer.doFrame(Choreographer.java:658) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897) at android.os.Handler.handleCallback(Handler.java:790) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:7000) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:441) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408) threads.txt

marchbold commented 2 years ago

The threads just all look like normal background threads relating to crashlytics so not sure they are causing the issue? I don't believe crashytics will ever call View.getVisibility() so I can't imagine that is the cause here.

The ZygoteInit at the beginning of that stack trace normally is associated with Android application startup, so are you doing any visibility checks or something at startup? Might be something @ajwfrost needs to look into with the AIR startup ?

Dima107 commented 2 years ago

I don't think I check vsibility by myself. I call only one thing similar to "visibily" in the game - AdView show() and hide(). But I don't do it on startup.

Also I wanna note that I see just "java.lang.NullPointerException" into Google Play Console without any words about "android.view.View.getVisibility()"

Dima107 commented 2 years ago

I wanna update crash info. We have the same crash for Android 10. Differece is just in line number Android 10 - 99%

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getVisibility()' on a null object reference at android.widget.FrameLayout.layoutChildren(FrameLayout.java:284) at android.widget.FrameLayout.onLayout(FrameLayout.java:270) at android.view.View.layout(View.java:21927) at android.view.ViewGroup.layout(ViewGroup.java:6260) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332) at android.widget.FrameLayout.onLayout(FrameLayout.java:270) at android.view.View.layout(View.java:21927) at android.view.ViewGroup.layout(ViewGroup.java:6260) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1829) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1673) at android.widget.LinearLayout.onLayout(LinearLayout.java:1582) at android.view.View.layout(View.java:21927) at android.view.ViewGroup.layout(ViewGroup.java:6260) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332) at android.widget.FrameLayout.onLayout(FrameLayout.java:270) at com.android.internal.policy.DecorView.onLayout(DecorView.java:779) at android.view.View.layout(View.java:21927) at android.view.ViewGroup.layout(ViewGroup.java:6260) at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:3088) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2598) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1726) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7610) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1052) at android.view.Choreographer.doCallbacks(Choreographer.java:875) at android.view.Choreographer.doFrame(Choreographer.java:810) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1037) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loop(Looper.java:214) at android.app.ActivityThread.main(ActivityThread.java:7386) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1072)

ajwfrost commented 2 years ago

Can I check what this means:

Android 10 - 99%

As if that means they're seeing this in 99% of attempts, then I would hope it's reproducible..! The only thing I can think of from that call stack is if we've got a view added to the layout which is null - or if we change the number of children while their function is running, perhaps in response to a layout callback.

We can check on this but any info on the devices etc would be good. Can you please confirm whether you have the HARMAN/AIR splash screen being displayed, as this makes a difference to the view stack..?

thanks

ajwfrost commented 2 years ago

So looking at the call stack: android.view.ViewRootImpl.performLayout calls android.widget.FrameLayout.onLayout(FrameLayout.java:270) which makes sense: at the root of our activity we have setContentView with a FrameLayout object.

This triggers the ViewGroup layout which goes through each View and then the call here is triggered to: android.widget.LinearLayout.onLayout(LinearLayout.java:1582)

It looks like we have three locations where LinearLayout is being used: 1) Listen error dialog 2) Remote debugger dialog 3) Expandable file chooser

So if one of these uses a FrameLayout which also then contains a FrameLayout but where one of the elements ends up null (or if the loop could end up out of bounds by the group changing), then we have a culprit..

Listen error dialog -> just has a text view Remote debugger dialog -> has a text view and an edit text view Expandable file chooser -> loads a view from resources: either LinearLayout containing CheckBox and LinearLayout with 2x TextView; or just a LinearLayout containing 2x TextView

So it doesn't seem to be this. The other thing we could be adding is a web view .. or I just noticed the fact you're adding some ad view ..?

Looking at the Android source for this part, it's not that you're calling show/hide or anything, it's just the automatic laying out of elements and it's trying to decide upon placement of elements so it needs to know which are invisible and therefore don't impact the layout.

Are you able to reproduce this yourselves btw? If so can you try excluding the advertising bit, or can we have the APK to take a look?

thanks

Dima107 commented 2 years ago

Unfortunately we can't reproduce this crash. I take all crash logs from Firebase Crashlitycs console and GoogplayConsole.

"Android 10 - 99%" it means that 99% of devices that were crashed had Android 10. (at android.widget.FrameLayout.layoutChildren(FrameLayout.java:284)) "Android 9 - 64%, Android 8 - 35%" it means that 99% of device that were crashed had Android 8 or 9. (at android.widget.FrameLayout.layoutChildren(FrameLayout.java:275))) I just wanted to say that crashes for Android 8, 9, and 10 has almost the same crashes. Difference is in line number.

Our app is video game. We have these crashes on release version. So I don't this this is "Listen error dialog, Remote debugger dialog or Expandable file chooser".

We show ads. So I think it's can be source of these crashes. We'll try optimize usage of ads.

Thank you

Dima107 commented 2 years ago

Harman splash sreen is not displayed in our game

marchbold commented 2 years ago

@Dima107 If you are adding an advert to your app too early (before AIR has completed initialising) I potentially could see a case where this occurs depending on how long AIR takes to init the main view. I'd suggest checking when you create / show your ad and try waiting until your AIR content is visible (added to stage event or something similar).

Dima107 commented 2 years ago

We add Adverts after Starling complete initializing(Starling root class is added to Stage). I think Starling does it after AIR complete initialising

marchbold commented 2 years ago

Do you have any other native extensions that add UI to the app?

Dima107 commented 2 years ago
  1. InAppBilling. We request inapps on app launch to determine if user's GooglePlayPass is activated.
  2. GameServices is temporary disabled.
marchbold commented 2 years ago

IAB or GameServices shouldn't add any view components related to the above error so I doubt those are the issue.

jigtrap commented 4 months ago

Hi, I know it's been more than two years since last post in this issue, I don't know the state of this issue, but Play Console has reported the same crash in my app.

Is the more frequent crash my app have with 72% of the total Crash Rate get_visibility

@ajwfrost , please let me know if I should start another issue or this post already works.

(Log from Android Vitals) Stack trace 1 Sample attributes: motorola hawaiip (moto g22) Android 12 (SDK 31) Version: 1000093Occurred: 4 hours ago Type java.lang.NullPointerException Exception java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getVisibility()' on a null object reference at android.widget.FrameLayout.layoutChildren (FrameLayout.java:284) at android.widget.FrameLayout.onLayout (FrameLayout.java:270) at android.view.View.layout (View.java:23305) at android.view.ViewGroup.layout (ViewGroup.java:6482) at android.widget.FrameLayout.layoutChildren (FrameLayout.java:332) at android.widget.FrameLayout.onLayout (FrameLayout.java:270) at android.view.View.layout (View.java:23305) at android.view.ViewGroup.layout (ViewGroup.java:6482) at android.widget.LinearLayout.setChildFrame (LinearLayout.java:1829) at android.widget.LinearLayout.layoutVertical (LinearLayout.java:1673) at android.widget.LinearLayout.onLayout (LinearLayout.java:1582) at android.view.View.layout (View.java:23305) at android.view.ViewGroup.layout (ViewGroup.java:6482) at android.widget.FrameLayout.layoutChildren (FrameLayout.java:332) at android.widget.FrameLayout.onLayout (FrameLayout.java:270) at com.android.internal.policy.DecorView.onLayout (DecorView.java:829) at android.view.View.layout (View.java:23305) at android.view.ViewGroup.layout (ViewGroup.java:6482) at android.view.ViewRootImpl.performLayout (ViewRootImpl.java:3866) at android.view.ViewRootImpl.performTraversals (ViewRootImpl.java:3298) at android.view.ViewRootImpl.doTraversal (ViewRootImpl.java:2235) at android.view.ViewRootImpl$TraversalRunnable.run (ViewRootImpl.java:9028) at android.view.Choreographer$CallbackRecord.run (Choreographer.java:1105) at android.view.Choreographer.doCallbacks (Choreographer.java:896) at android.view.Choreographer.doFrame (Choreographer.java:815) at android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:1090) at android.os.Handler.handleCallback (Handler.java:938) at android.os.Handler.dispatchMessage (Handler.java:99) at android.os.Looper.loopOnce (Looper.java:223) at android.os.Looper.loop (Looper.java:317) at android.app.ActivityThread.main (ActivityThread.java:7942) at java.lang.reflect.Method.invoke at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:568) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1045)

Thanks in advance, Aldo

jigtrap commented 4 months ago

Forgot to mention what I'm using :

Adobe AIR SDK 50.2.5.1 Anes: Distriqt InAppBilling and Adverts I dont use any dialog besides the ones related to the ANEs (including Google Play Admob Consent Message via UMP) I started to use InAppBilling and Adverts after Event.ADDED_TO_STAGE.

If you need any other information please just let me know.

Thanks in advance Aldo

jigtrap commented 3 weeks ago

@ajwfrost , hello, any news about it?

ajwfrost commented 3 weeks ago

We haven't any way to find this one out or fix it I'm afraid, unless we're able to get a way to reproduce it. The crash happens purely within Android's own code, caused by a lack of defensive programming. At a guess there is some condition where a list is changing whilst they're iterating through it, which is something we might be able to find a workaround for - but equally, we might not, and the only definite fix for this would have to come from Google..

thanks

jigtrap commented 3 weeks ago

I understand, thanks.