enteraname74 / SoulSearching

A music player for Android and Desktop using Compose Multiplatform.
GNU General Public License v3.0
77 stars 4 forks source link

Crash of the player in background on lateinit property playerViewModel has not been initialized #21

Closed Porkepix closed 6 months ago

Porkepix commented 10 months ago

Player wasn't used but was running in background and crashed at some point on this exception after unlocking the phone:

01-10 10:59:22.550  1453 16726 I WindowManager: WIN DEATH: Window{7a24489 u0 com.github.enteraname74.soulsearching/com.github.soulsearching.MainActivity}
01-10 10:59:22.551  1453 12807 I ActivityManager: Process com.github.enteraname74.soulsearching (pid 11630) has died: prcp FGS
01-10 10:59:22.554  1453 12807 W ActivityManager: Scheduling restart of crashed service com.github.enteraname74.soulsearching/com.github.soulsearching.service.PlayerService in 1000ms
01-10 10:59:22.563  1453  1526 W ActivityManager: setHasOverlayUi called on unknown pid: 11630
01-10 10:59:23.648  1453  1496 I ActivityManager: Start proc 26165:com.github.enteraname74.soulsearching/u0a248 for service com.github.enteraname74.soulsearching/com.github.soulsearching.service.PlayerService
01-10 10:59:24.100 26165 26165 E AndroidRuntime: FATAL EXCEPTION: main
01-10 10:59:24.100 26165 26165 E AndroidRuntime: Process: com.github.enteraname74.soulsearching, PID: 26165
01-10 10:59:24.100 26165 26165 E AndroidRuntime: java.lang.RuntimeException: Unable to start service com.github.soulsearching.service.PlayerService@f338d06 with null: androidx.fragment.app.d: lateinit property playerViewModel has not been initialized
01-10 10:59:24.100 26165 26165 E AndroidRuntime:    at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3561)
01-10 10:59:24.100 26165 26165 E AndroidRuntime:    at android.app.ActivityThread.-wrap20(Unknown Source:0)
01-10 10:59:24.100 26165 26165 E AndroidRuntime:    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1703)
01-10 10:59:24.100 26165 26165 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:105)
01-10 10:59:24.100 26165 26165 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:251)
01-10 10:59:24.100 26165 26165 E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:6572)
01-10 10:59:24.100 26165 26165 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
01-10 10:59:24.100 26165 26165 E AndroidRuntime:    at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
01-10 10:59:24.100 26165 26165 E AndroidRuntime:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
01-10 10:59:24.100 26165 26165 E AndroidRuntime: Caused by: androidx.fragment.app.d: lateinit property playerViewModel has not been initialized
01-10 10:59:24.100 26165 26165 E AndroidRuntime:    at p4.e.<init>(Unknown Source:395)
01-10 10:59:24.100 26165 26165 E AndroidRuntime:    at com.github.soulsearching.service.PlayerService.onStartCommand(Unknown Source:16)
01-10 10:59:24.100 26165 26165 E AndroidRuntime:    at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3544)
01-10 10:59:24.100 26165 26165 E AndroidRuntime:    ... 8 more
01-10 10:59:24.105  1453 12807 D ActivityManager: New dropbox entry: com.github.enteraname74.soulsearching, data_app_crash, 90271a39-2246-422c-85e9-f0dd9758e2a8
01-10 10:59:24.112  1453  1497 I ActivityManager: Showing crash dialog for package com.github.enteraname74.soulsearching u0
01-10 10:59:24.132  1453  1496 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.DROPBOX_ENTRY_ADDED flg=0x10 (has extras) } to com.google.android.gms/.stats.service.DropBoxEntryAddedReceiver
01-10 10:59:24.132  1453  1496 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.DROPBOX_ENTRY_ADDED flg=0x10 (has extras) } to com.google.android.gms/.chimera.GmsIntentOperationService$PersistentTrustedReceiver
01-10 10:59:24.132  1453  1496 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.DROPBOX_ENTRY_ADDED flg=0x10 (has extras) } to com.sonyericsson.crashmonitor/.receiver.CrashMonitorServiceBroadcastReceiver
01-10 10:59:24.311  1453  1496 I ActivityManager: Start proc 26186:com.sonyericsson.crashmonitor/1000 for broadcast com.sonyericsson.crashmonitor/.receiver.CrashMonitorServiceBroadcastReceiver
01-10 10:59:39.736  1453 12807 I ActivityManager: Killing 26165:com.github.enteraname74.soulsearching/u0a248 (adj 200): crash

Device details: Xperia XZ running Android Oreo (8.0) on stock ROM.

enteraname74 commented 10 months ago

Thank you for providing information for this error. I will see what I can do to fix this.

enteraname74 commented 6 months ago

I have reworked the way this ViewModel is initialized. This problem should no longer appears.