TeamNewPipe / NewPipe

A libre lightweight streaming front-end for Android.
https://newpipe.net
GNU General Public License v3.0
31.26k stars 3.03k forks source link

Playing a video causes app crash [Android 7 - Lenovo] - caused by NullPointer in SurfaceView.updateWindow #7549

Open 0xTyagi opened 2 years ago

0xTyagi commented 2 years ago

Checklist

Steps to reproduce the bug

1.Open any video.

  1. Play video. 3.Change Orientation (either automatically or manually). Or press the back button.
  2. App crash

    Actual behavior

    App crash

    Expected behavior

    Videos must be played without any carsh

    Screenshots/Screen recordings

    Not required.

    Logs

    Exception

    • User Action: ui error
    • Request: ACRA report
    • Content Country: GB
    • Content Language: en
    • App Language: en_IN
    • Service: none
    • Version: 0.21.14
    • OS: Linux Android 7.0 - 24
      Crash log

    java.lang.RuntimeException: Unable to stop service org.schabi.newpipe.player.MainPlayer@264a0e5: java.lang.NullPointerException: Attempt to invoke interface method 'void android.view.IWindowSession.performDeferredDestroy(android.view.IWindow)' on a null object reference
        at android.app.ActivityThread.handleStopService(ActivityThread.java:3344)
        at android.app.ActivityThread.-wrap27(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1570)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6077)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
    Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'void android.view.IWindowSession.performDeferredDestroy(android.view.IWindow)' on a null object reference
        at android.view.SurfaceView.updateWindow(SurfaceView.java:658)
        at android.view.SurfaceView.onWindowVisibilityChanged(SurfaceView.java:255)
        at android.view.View.dispatchDetachedFromWindow(View.java:15437)
        at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3222)
        at android.view.ViewGroup.removeViewInternal(ViewGroup.java:4758)
        at android.view.ViewGroup.removeViewInternal(ViewGroup.java:4732)
        at android.view.ViewGroup.removeView(ViewGroup.java:4663)
        at org.schabi.newpipe.player.MainPlayer.removeViewFromParent(MainPlayer.java:240)
        at org.schabi.newpipe.player.MainPlayer.cleanup(MainPlayer.java:187)
        at org.schabi.newpipe.player.MainPlayer.onDestroy(MainPlayer.java:178)
        at android.app.ActivityThread.handleStopService(ActivityThread.java:3327)
        ... 8 more
    


AudricV commented 2 years ago

What's your device and your device's ROM? It seems you removed this part when filling the template.

I couldn't reproduce this issue on my device (Honor 9X, EMUI 10.0/Android 10).

Kariosfox commented 2 years ago

I'm also experiencing this issue. I'm using a Lenovo P2a42 with Android 7.0.

0xTyagi commented 2 years ago

OS: Android 24(7.0) stock Device: Lenovo k33

0xTyagi commented 2 years ago

This crash log may also be related to this

Exception

java.lang.RuntimeException: Unable to destroy activity {org.schabi.newpipe/org.schabi.newpipe.MainActivity}: java.lang.NullPointerException: Attempt to invoke interface method 'void android.view.IWindowSession.performDeferredDestroy(android.view.IWindow)' on a null object reference
    at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4167)
    at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:4185)
    at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4459)
    at android.app.ActivityThread.-wrap19(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1466)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6077)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'void android.view.IWindowSession.performDeferredDestroy(android.view.IWindow)' on a null object reference
    at android.view.SurfaceView.updateWindow(SurfaceView.java:658)
    at android.view.SurfaceView.onWindowVisibilityChanged(SurfaceView.java:255)
    at android.view.View.dispatchDetachedFromWindow(View.java:15437)
    at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3222)
    at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3222)
    at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3222)
    at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3222)
    at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3222)
    at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3222)
    at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3222)
    at android.view.ViewGroup.removeViewInternal(ViewGroup.java:4758)
    at android.view.ViewGroup.removeViewInternal(ViewGroup.java:4732)
    at android.view.ViewGroup.removeView(ViewGroup.java:4663)
    at androidx.fragment.app.FragmentContainerView.removeView(FragmentContainerView.java:350)
    at androidx.fragment.app.SpecialEffectsController$Operation$State.applyState(SpecialEffectsController.java:452)
    at androidx.fragment.app.SpecialEffectsController$1.run(SpecialEffectsController.java:211)
    at androidx.fragment.app.SpecialEffectsController$Operation.complete(SpecialEffectsController.java:695)
    at androidx.fragment.app.SpecialEffectsController$FragmentStateManagerOperation.complete(SpecialEffectsController.java:744)
    at androidx.fragment.app.SpecialEffectsController$Operation.cancel(SpecialEffectsController.java:597)
    at androidx.fragment.app.SpecialEffectsController.forceCompleteAllOperations(SpecialEffectsController.java:332)
    at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:3132)
    at androidx.fragment.app.FragmentManager.dispatchDestroy(FragmentManager.java:3107)
    at androidx.fragment.app.FragmentController.dispatchDestroy(FragmentController.java:334)
    at androidx.fragment.app.FragmentActivity.onDestroy(FragmentActivity.java:330)
    at androidx.appcompat.app.AppCompatActivity.onDestroy(AppCompatActivity.java:278)
    at org.schabi.newpipe.MainActivity.onDestroy(MainActivity.java:446)
    at android.app.Activity.performDestroy(Activity.java:6907)
    at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1154)
    at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4154)
    ... 10 more


0xTyagi commented 2 years ago

This comment may be helpful as this issues also have same crash signature.

https://github.com/lipangit/JiaoZiVideoPlayer/issues/62#issuecomment-217357273

Kariosfox commented 2 years ago

This issue is also present in the newest version 21.15.

vit1307 commented 2 years ago

I'm also expiriensing crashes on Lenovo P2. You don't even need to play any video, just scroll a little bit to crash with something like this:

Exception

android.content.res.Resources$NotFoundException: Plural resource ID #0x7f10000d quantity=47701 item=one
    at android.content.res.ResourcesImpl.getQuantityText(ResourcesImpl.java:277)
    at android.content.res.Resources.getQuantityText(Resources.java:358)
    at android.content.res.Resources.getQuantityString(Resources.java:434)
    at org.schabi.newpipe.util.Localization.getQuantity(Localization.java:252)
    at org.schabi.newpipe.util.Localization.shortViewCount(Localization.java:220)
    at org.schabi.newpipe.info_list.holder.StreamInfoItemHolder.getStreamInfoDetailLine(StreamInfoItemHolder.java:80)
    at org.schabi.newpipe.info_list.holder.StreamInfoItemHolder.updateFromItem(StreamInfoItemHolder.java:66)
    at org.schabi.newpipe.info_list.InfoListAdapter.onBindViewHolder(InfoListAdapter.java:337)
    at org.schabi.newpipe.info_list.InfoListAdapter.onBindViewHolder(InfoListAdapter.java:360)
    at androidx.recyclerview.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:7337)
    at androidx.recyclerview.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:6194)
    at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:6460)
    at androidx.recyclerview.widget.GapWorker.prefetchPositionWithDeadline(GapWorker.java:288)
    at androidx.recyclerview.widget.GapWorker.flushTaskWithDeadline(GapWorker.java:345)
    at androidx.recyclerview.widget.GapWorker.flushTasksWithDeadline(GapWorker.java:361)
    at androidx.recyclerview.widget.GapWorker.prefetch(GapWorker.java:368)
    at androidx.recyclerview.widget.GapWorker.run(GapWorker.java:399)
    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:6111)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)


litetex commented 2 years ago

https://github.com/TeamNewPipe/NewPipe/issues/7549#issuecomment-997334348 is the same exception as in the issue

https://github.com/TeamNewPipe/NewPipe/issues/7549#issuecomment-1017855193 is an unrelated exception

Note: It looks like the problem only happens on Android 7.0 (as seen in the crash reports) and on Lenovo devices.

Analysis

The problem occurs inside the Android framework itself (likely here) however I was unable to located any source/branch which exactly matches the line numbers. So some kind of modification was likely done inside the class by the device manufacturer.

The problematic code is no longer present in Android 8+ and was likely fixed by a refactoring, adding a null check and the catching of all exceptions with this commit: grafik

TL;DR The problem is not fixable by us as it's a Android problem or a problem introduced by a modification from the manufacturer of the device (likely Lenovo). Android 8+ provides a fix so I recommend updating the OS if possible.

litetex commented 2 years ago

In a duplicate issue the reporter stated that s/he also uses a Lenovo device - I'm now 99% sure that there is a bug in Lenovo's Android 7 OS.

jjakob commented 2 years ago
I have probably the same bug on LineageOS 14.1 Android 7.1.2 ``` java.lang.NullPointerException: Attempt to invoke interface method 'void android.view.IWindowSession.finishDrawing(android.view.IWindow)' on a null object reference at android.view.SurfaceView.updateWindow(SurfaceView.java:652) at android.view.SurfaceView.onWindowVisibilityChanged(SurfaceView.java:247) at android.view.View.dispatchWindowVisibilityChanged(View.java:10358) at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1290) at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1290) at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1290) at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1290) at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1290) at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1290) at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1290) at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1290) at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1290) at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1290) at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1290) at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1290) at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1290) at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1290) at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1290) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1544) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1254) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6344) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:874) at android.view.Choreographer.doCallbacks(Choreographer.java:686) at android.view.Choreographer.doFrame(Choreographer.java:621) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:860) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95)\n\tat android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6186) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779) ```
celikten commented 2 years ago

Reply to: https://github.com/TeamNewPipe/NewPipe/issues/7549#issuecomment-1020436139 (Mod-note: removed quote reply because it requires massive amounts of space)

As I remember correctly, the previous versions of the NewPipe versions (before 0.21.14) have worked properly. , and I loved putting something in the background and closing the phone screen.

Is this crash only related to the android version? Can not it be another bug?

litetex commented 2 years ago

Is this crash only related to the android version? Can not it be another bug?

→ see above

The problem is not fixable by us as it's a Android problem or a problem introduced by a modification from the manufacturer of the device (likely Lenovo). Android 8+ provides a fix so I recommend updating the OS if possible.