facebook/stetho

App crashes during work

Manwtein opened this issue ยท 9 comments

Hello, i'm trying to use the library and my browser shows me a list of my requests, but when i hide some fragments my app crashes.
My app takes the following steps. Open Activity and Fragment -> Open DialogFragment + send request -> Open nested DialogFragment(into childFragmentManager) -> Close nested DialogFragment -> Close DialogFragment(back to Activity) and i get an error message.
I'm trying to figure out why this doesn't work, but I don't know why one of the children of ElementInfo is null. And I see the same problem in the past, sorry if there is a solution, but I cannot find it.

java.lang.NullPointerException: Attempt to read from field 'java.lang.Object com.facebook.stetho.inspector.elements.ElementInfo.parentElement' on a null object reference at com.facebook.stetho.inspector.elements.ShadowDocument$Update.removeGarbageSubTree(ShadowDocument.java:378) at com.facebook.stetho.inspector.elements.ShadowDocument$Update.removeGarbageSubTree(ShadowDocument.java:386) at com.facebook.stetho.inspector.elements.ShadowDocument$Update.removeGarbageSubTree(ShadowDocument.java:386) at com.facebook.stetho.inspector.elements.ShadowDocument$Update.removeGarbageSubTree(ShadowDocument.java:386) at com.facebook.stetho.inspector.elements.ShadowDocument$Update.commit(ShadowDocument.java:360) at com.facebook.stetho.inspector.elements.Document.applyDocumentUpdate(Document.java:494) at com.facebook.stetho.inspector.elements.Document.updateTree(Document.java:346) at com.facebook.stetho.inspector.elements.Document.access$1200(Document.java:31) at com.facebook.stetho.inspector.elements.Document$ProviderListener.onPossiblyChanged(Document.java:720) at com.facebook.stetho.inspector.elements.android.AndroidDocumentProvider$1.run(AndroidDocumentProvider.java:71) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6119) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

I'm getting the same error while using Stetho 1.5.1.

    java.lang.NullPointerException: Attempt to read from field 'java.lang.Object com.facebook.stetho.inspector.elements.ElementInfo.parentElement' on a null object reference
        at com.facebook.stetho.inspector.elements.ShadowDocument$Update.removeGarbageSubTree(ShadowDocument.java:378)
        at com.facebook.stetho.inspector.elements.ShadowDocument$Update.removeGarbageSubTree(ShadowDocument.java:386)
        at com.facebook.stetho.inspector.elements.ShadowDocument$Update.removeGarbageSubTree(ShadowDocument.java:386)
        at com.facebook.stetho.inspector.elements.ShadowDocument$Update.removeGarbageSubTree(ShadowDocument.java:386)
        at com.facebook.stetho.inspector.elements.ShadowDocument$Update.commit(ShadowDocument.java:360)
        at com.facebook.stetho.inspector.elements.Document.applyDocumentUpdate(Document.java:494)
        at com.facebook.stetho.inspector.elements.Document.updateTree(Document.java:346)
        at com.facebook.stetho.inspector.elements.Document.access$1200(Document.java:31)
        at com.facebook.stetho.inspector.elements.Document$ProviderListener.onPossiblyChanged(Document.java:720)
        at com.facebook.stetho.inspector.elements.android.AndroidDocumentProvider$1.run(AndroidDocumentProvider.java:71)
        at android.os.Handler.handleCallback(Handler.java:873)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6669)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

I'm getting the same error ( Stetho version 1.5.1)

java.lang.NullPointerException: Attempt to read from field 'java.lang.Object com.facebook.stetho.inspector.elements.ElementInfo.parentElement' on a null object reference
        at com.facebook.stetho.inspector.elements.ShadowDocument$Update.removeGarbageSubTree(ShadowDocument.java:378)
        at com.facebook.stetho.inspector.elements.ShadowDocument$Update.removeGarbageSubTree(ShadowDocument.java:386)
        at com.facebook.stetho.inspector.elements.ShadowDocument$Update.removeGarbageSubTree(ShadowDocument.java:386)
        at com.facebook.stetho.inspector.elements.ShadowDocument$Update.removeGarbageSubTree(ShadowDocument.java:386)
        at com.facebook.stetho.inspector.elements.ShadowDocument$Update.commit(ShadowDocument.java:360)
        at com.facebook.stetho.inspector.elements.Document.applyDocumentUpdate(Document.java:494)
        at com.facebook.stetho.inspector.elements.Document.updateTree(Document.java:346)
        at com.facebook.stetho.inspector.elements.Document.access$1200(Document.java:31)
        at com.facebook.stetho.inspector.elements.Document$ProviderListener.onPossiblyChanged(Document.java:720)
        at com.facebook.stetho.inspector.elements.android.AndroidDocumentProvider$1.run(AndroidDocumentProvider.java:71)
        at android.os.Handler.handleCallback(Handler.java:761)
        at android.os.Handler.dispatchMessage(Handler.java:98)
        at android.os.Looper.loop(Looper.java:156)
        at android.app.ActivityThread.main(ActivityThread.java:6623)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)

I get this issue often. Usually it happens when I have the stetho window open and a bloated fragment transaction happens

2019-06-27 12:37:24.003 11630-11630/com.procore.activities.debug E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.procore.activities.debug, PID: 11630
    java.lang.NullPointerException: Attempt to read from field 'java.lang.Object com.facebook.stetho.inspector.elements.ElementInfo.parentElement' on a null object reference
        at com.facebook.stetho.inspector.elements.ShadowDocument$Update.removeGarbageSubTree(ShadowDocument.java:378)
        at com.facebook.stetho.inspector.elements.ShadowDocument$Update.removeGarbageSubTree(ShadowDocument.java:386)
        at com.facebook.stetho.inspector.elements.ShadowDocument$Update.removeGarbageSubTree(ShadowDocument.java:386)
        at com.facebook.stetho.inspector.elements.ShadowDocument$Update.removeGarbageSubTree(ShadowDocument.java:386)
        at com.facebook.stetho.inspector.elements.ShadowDocument$Update.removeGarbageSubTree(ShadowDocument.java:386)
        at com.facebook.stetho.inspector.elements.ShadowDocument$Update.commit(ShadowDocument.java:360)
        at com.facebook.stetho.inspector.elements.Document.applyDocumentUpdate(Document.java:494)
        at com.facebook.stetho.inspector.elements.Document.updateTree(Document.java:346)
        at com.facebook.stetho.inspector.elements.Document.access$1200(Document.java:31)
        at com.facebook.stetho.inspector.elements.Document$ProviderListener.onPossiblyChanged(Document.java:720)
        at com.facebook.stetho.inspector.elements.android.AndroidDocumentProvider$1.run(AndroidDocumentProvider.java:71)
        at android.os.Handler.handleCallback(Handler.java:789)
        at android.os.Handler.dispatchMessage(Handler.java:98)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6541)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

problem error
2019-08-16 14:39:10.049 16110-16110/net.gcatech.traces E/AndroidRuntime: FATAL EXCEPTION: main
Process: net.gcatech.traces, PID: 16110
java.lang.NullPointerException: Attempt to read from field 'java.lang.Object com.facebook.stetho.inspector.elements.ElementInfo.parentElement' on a null object reference
at com.facebook.stetho.inspector.elements.ShadowDocument$Update.removeGarbageSubTree(ShadowDocument.java:378)
at com.facebook.stetho.inspector.elements.ShadowDocument$Update.removeGarbageSubTree(ShadowDocument.java:386)
at com.facebook.stetho.inspector.elements.ShadowDocument$Update.removeGarbageSubTree(ShadowDocument.java:386)
at com.facebook.stetho.inspector.elements.ShadowDocument$Update.removeGarbageSubTree(ShadowDocument.java:386)
at com.facebook.stetho.inspector.elements.ShadowDocument$Update.removeGarbageSubTree(ShadowDocument.java:386)
at com.facebook.stetho.inspector.elements.ShadowDocument$Update.commit(ShadowDocument.java:360)
at com.facebook.stetho.inspector.elements.Document.applyDocumentUpdate(Document.java:494)
at com.facebook.stetho.inspector.elements.Document.updateTree(Document.java:346)
at com.facebook.stetho.inspector.elements.Document.access$1200(Document.java:31)
at com.facebook.stetho.inspector.elements.Document$ProviderListener.onPossiblyChanged(Document.java:720)
at com.facebook.stetho.inspector.elements.android.AndroidDocumentProvider$1.run(AndroidDocumentProvider.java:71)
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:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

Any update on this issue?

2019-10-07 13:24:49.111 20220-20220/ru.iqsolution.tkoonline E/AndroidRuntime: FATAL EXCEPTION: main
    Process: ru.iqsolution.tkoonline, PID: 20220
    java.lang.NullPointerException: Attempt to read from field 'java.lang.Object com.facebook.stetho.inspector.elements.ElementInfo.parentElement' on a null object reference
        at com.facebook.stetho.inspector.elements.ShadowDocument$Update.removeGarbageSubTree(ShadowDocument.java:378)
        at com.facebook.stetho.inspector.elements.ShadowDocument$Update.removeGarbageSubTree(ShadowDocument.java:386)
        at com.facebook.stetho.inspector.elements.ShadowDocument$Update.removeGarbageSubTree(ShadowDocument.java:386)
        at com.facebook.stetho.inspector.elements.ShadowDocument$Update.removeGarbageSubTree(ShadowDocument.java:386)
        at com.facebook.stetho.inspector.elements.ShadowDocument$Update.commit(ShadowDocument.java:360)
        at com.facebook.stetho.inspector.elements.Document.applyDocumentUpdate(Document.java:494)
        at com.facebook.stetho.inspector.elements.Document.updateTree(Document.java:346)
        at com.facebook.stetho.inspector.elements.Document.access$1200(Document.java:31)
        at com.facebook.stetho.inspector.elements.Document$ProviderListener.onPossiblyChanged(Document.java:720)
        at com.facebook.stetho.inspector.elements.android.AndroidDocumentProvider$1.run(AndroidDocumentProvider.java:71)
        at android.os.Handler.handleCallback(Handler.java:869)
        at android.os.Handler.dispatchMessage(Handler.java:101)
        at android.os.Looper.loop(Looper.java:206)
        at android.app.ActivityThread.main(ActivityThread.java:6735)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:845)

Still waiting for #655 to be merged. Maybe @jasta could help on that front.

9th of April is the timestamp of the first message in the thread. It is half of the year already. What is the ETA of accepting the PR that plumbs the issue? At least comment if you don't agree with the solution.

Could some contributor please help us with the issue? There are several pull request related to this null pointer exception crash. Or is this library unmaintained or deprecated? @mathroule @jasta

Here's the fix:

    implementation 'com.github.mathroule.stetho:stetho:bugfix~issue-652-SNAPSHOT'
    implementation("com.facebook.stetho:stetho-okhttp3:1.5.1") {
        exclude group: 'com.facebook.stetho'
    }

and add jitpack to your repositories:

buildscript {
    repositories {
        maven {
            url 'https://maven.fabric.io/public'
        }
    }
}