fast4x / RiMusic

A multilingual Android application for streaming music from YouTube Music.
https://rimusic.xyz
GNU General Public License v3.0
2.22k stars 113 forks source link

Crash: java.lang.NullPointerException: Attempt to invoke virtual method [...] on a null object reference #2732

Closed twistios closed 2 months ago

twistios commented 3 months ago

Steps to reproduce the bug

A random crash. Probably it has something to do with playback beeing stop.

Expected behavior

Not Crash.

Actual behavior

A java.lang.NullPointerException Crash.

Screenshots/Screen recordings

No response

Logs

Details

```` 2024-07-13T00:29:45.760: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Class java.lang.Object.getClass()' on a null object reference s0.k.a(SourceFile:125) p0.f.onPreDraw(SourceFile:34) android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:1204) android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:4723) android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:3288) android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:11344) android.view.Choreographer$CallbackRecord.run(Choreographer.java:1689) android.view.Choreographer$CallbackRecord.run(Choreographer.java:1698) android.view.Choreographer.doCallbacks(Choreographer.java:1153) android.view.Choreographer.doFrame(Choreographer.java:1079) android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1646) android.os.Handler.handleCallback(Handler.java:958) android.os.Handler.dispatchMessage(Handler.java:99) android.os.Looper.loopOnce(Looper.java:230) android.os.Looper.loop(Looper.java:319) android.app.ActivityThread.main(ActivityThread.java:8919) java.lang.reflect.Method.invoke(Native Method) com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:578) com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103) ````

RiMusic version

0.6.43

Android version

14

Additional information

No response

fast4x commented 3 months ago

Your kog not talk about nothing, i can't get reproduce this bug.

fast4x commented 3 months ago

I'll add a workaround for log to add other info

fast4x commented 3 months ago

Please download, try new custom version and send new log. https://github.com/fast4x/RiMusic/tree/master/customVersion

fast4x commented 3 months ago

Do you have background cover in player? If yes, change it without cover. The problem would be in blur effect...

twistios commented 3 months ago

I am using background cover. This crash did not happen since then, it might need some more time. So I also can not post a new crash log with the customVersion.

twistios commented 3 months ago

I am using background cover. This crash did not happen since then, it might need some more time. So I also can not post a new crash log with the customVersion.

Correction, currently I am NOT using background cover.

fast4x commented 3 months ago

Use Blurred background?

twistios commented 3 months ago

Background colors: Match song cover

fast4x commented 3 months ago

try with other background not from cover...

fast4x commented 3 months ago

Feedback?

twistios commented 3 months ago

I was first using dynamic theme and also this one does work based on cover so it is not enough to use background from theme. So then I changed to Modern Black. But anyway, this crash only happened once until now so I have no idea if it was fixed by the customVersion or the settings or it is just rare.

twistios commented 3 months ago

Update: A null pointer crash just now. I think the app was not playing any songs before (I was just checking the settings, switched for a short periode to dynamic and then back to Modern black, maybe I was on the home screen but I did not play a song). The crash then did happen when I returned from background by clicking on the app-icon. I think it opened the settings page where I was before. Will post the log soon.

twistios commented 3 months ago

The content seems to be the same, but at least this time I was definitly not using background from cover (but maybe it reacted to the short switch to dynamic theme, but it happended after that).

Details

```` 2024-07-15T10:22:53.498: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Class java.lang.Object.getClass()' on a null object reference s0.k.a(SourceFile:125) p0.f.onPreDraw(SourceFile:34) android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:1204) android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:4723) android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:3288) android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:11344) android.view.Choreographer$CallbackRecord.run(Choreographer.java:1689) android.view.Choreographer$CallbackRecord.run(Choreographer.java:1698) android.view.Choreographer.doCallbacks(Choreographer.java:1153) android.view.Choreographer.doFrame(Choreographer.java:1079) android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1646) android.os.Handler.handleCallback(Handler.java:958) android.os.Handler.dispatchMessage(Handler.java:99) android.os.Looper.loopOnce(Looper.java:230) android.os.Looper.loop(Looper.java:319) android.app.ActivityThread.main(ActivityThread.java:8919) java.lang.reflect.Method.invoke(Native Method) com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:578) com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103) ````

fast4x commented 3 months ago

where happen this?

twistios commented 3 months ago

where happen this?

Update: A null pointer crash just now. I think the app was not playing any songs before (I was just checking the settings, switched for a short periode to dynamic and then back to Modern black, maybe I was on the home screen but I did not play a song). The crash then did happen when I returned from background by clicking on the app-icon. I think it opened the settings page where I was before. Will post the log soon.

The app was in background and than I opened it by clicking on the app icon.

twistios commented 3 months ago

I was able to find p0.f.onPreDraw in the decompiled APK. Screenshot from 2024-07-16 22-47-07

I know it is kind of useless, but anyway. :smiley: Or maybe not, for example I guess it crashes here: kVar.a(kVar.f27108b) (s0.k.a(SourceFile:125)). And based on the code it seems to be related to images.

twistios commented 3 months ago

Yesterday I also improved the decompiled code section a bit (by hand). So here is the code section again (names are based on what it does/is):

Details

````java public /* synthetic */ OnPreDrawListenerImpl(int i8, Object obj) { this.f26049s = i8; // 0 or 1 this.layout = obj; // CoordinatorLayout (CoordinatorLayoutV2) } public final boolean onPreDraw() { switch (this.f26049s) { case 0: CoordinatorLayoutV2 cLayout = (CoordinatorLayoutV2) this.layout; HandlerCompatClass handlerCompatClassVar = cLayout.handlerCompatClassVar; ImageReader imageReader = handlerCompatClassVar.imageReader; if (imageReader != null) { imageReader.close(); } handlerCompatClassVar.imageReader = null; handlerCompatClassVar.a(handlerCompatClassVar.hashTableClass); cLayout.viewGroup.getViewTreeObserver().removeOnPreDrawListener(this); cLayout.f26058f = false; return true; default: // 1 ((CoordinatorLayout) this.layout).p(0); return true; } } ````

CoordinatorLayoutV2 is either CoordinatorLayout or a subclass. The same goes for handlerCompatClassVar.

twistios commented 3 months ago

I was finally able to capture the exception on a screencapture. It was playing "Levels" by Avichii before it stopped on it's own. As it can be seen from the video, there is no notification. And it shows "Starstruck" as the current playing song. I think this is the song that was playing when I put the app into background. The play time is the one of "Starstruck", so the one for "Levels" was not shown yet. The crash happened multiple songs after putting to background. The NullPointerException then happened when I clicked on the app icon I think and there is NO log of when the music stopped on it's own.

https://github.com/user-attachments/assets/6d9d9025-0c85-4cb5-a3b8-fce13e66e940

twistios commented 2 months ago

I got the same crash with 0.6.44. This time the phone did not have network access and all songs were cached. It might be that it tried to connect to a Wifi-AP, but it was not connected to the internet. Also the crash happend in the background.

Details

```` 2024-07-21T23:41:11.955: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Class java.lang.Object.getClass()' on a null object reference s0.k.a(SourceFile:125) p0.f.onPreDraw(SourceFile:34) android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:1204) android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:4723) android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:3288) android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:11344) android.view.Choreographer$CallbackRecord.run(Choreographer.java:1689) android.view.Choreographer$CallbackRecord.run(Choreographer.java:1698) android.view.Choreographer.doCallbacks(Choreographer.java:1153) android.view.Choreographer.doFrame(Choreographer.java:1079) android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1646) android.os.Handler.handleCallback(Handler.java:958) android.os.Handler.dispatchMessage(Handler.java:99) android.os.Looper.loopOnce(Looper.java:230) android.os.Looper.loop(Looper.java:319) android.app.ActivityThread.main(ActivityThread.java:8919) java.lang.reflect.Method.invoke(Native Method) com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:578) com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103) ````