jellyfin / jellyfin-androidtv

Android TV Client for Jellyfin
https://jellyfin.org
GNU General Public License v2.0
2.87k stars 489 forks source link

Frequent crashes due to NullPointerException #2947

Closed krutburken closed 10 months ago

krutburken commented 1 year ago

Describe the bug

Honestly seems pretty random when it occurs. Perhaps more common when the app has been left idle for a short time and you try to resume it (not playback, just using the app). It can crash multiple times in a row with the same error.

I don't use Android TV on a daily basis so I can't say if only the latest beta is affected.

Logs

Stack Trace:

java.lang.NullPointerException
    at org.jellyfin.androidtv.ui.home.HomeFragmentHelper.loadResume(HomeFragmentHelper.kt:33)
    at org.jellyfin.androidtv.ui.home.HomeFragmentHelper.loadResumeVideo(HomeFragmentHelper.kt:51)
    at org.jellyfin.androidtv.ui.home.HomeRowsFragment$onCreate$1.invokeSuspend(HomeRowsFragment.kt:122)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
    at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:115)
    at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:103)
    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684)
    Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@4c269fd, Dispatchers.IO]

Logcat:

08-07 09:45:09.017 D/LeanbackChannelWorker( 2488): Updating channel content://android.media.tv/channel/10
08-07 09:45:09.035 D/LeanbackChannelWorker( 2488): Updating channel content://android.media.tv/channel/55
08-07 09:45:09.107 D/LeanbackChannelWorker( 2488): Updating channel content://android.media.tv/channel/56
08-07 09:45:09.189 D/LeanbackChannelWorker( 2488): Updating channel content://android.media.tv/channel/57
08-07 09:45:09.241 D/LeanbackChannelWorker( 2488): Updating channel content://android.media.tv/channel/9
08-07 09:45:09.310 I/WM-WorkerWrapper( 2488): Worker result SUCCESS for Work [ id=9c6c6e55-bdcc-4741-8b5b-cf906b38f151, tags={ org.jellyfin.androidtv.integration.LeanbackChannelWorker } ]
08-07 09:45:18.834 E/libc    ( 2488): Access denied finding property "ro.vendor.sys.NV_ASYNC"
08-07 09:45:18.834 E/libc    ( 2488): Access denied finding property "ro.vendor.sys.NV_LOGFPS"
08-07 09:45:18.835 E/libc    ( 2488): Access denied finding property "ro.vendor.sys.NV_PROCESS_NAME"
08-07 09:45:18.835 E/libc    ( 2488): Access denied finding property "ro.vendor.sys.NV_FPSDYNAMIC"
08-07 09:45:24.249 D/ACRA    ( 2488): onActivityPaused class org.jellyfin.androidtv.ui.browsing.MainActivity
08-07 09:45:24.789 E/libc    ( 2488): Access denied finding property "ro.vendor.sys.NV_ASYNC"
08-07 09:45:24.789 E/libc    ( 2488): Access denied finding property "ro.vendor.sys.NV_LOGFPS"
08-07 09:45:24.789 E/libc    ( 2488): Access denied finding property "ro.vendor.sys.NV_PROCESS_NAME"
08-07 09:45:24.789 E/libc    ( 2488): Access denied finding property "ro.vendor.sys.NV_FPSDYNAMIC"
08-07 09:45:24.915 E/Surface ( 2488): freeAllBuffers: 1 buffers were freed while being dequeued!
08-07 09:45:24.925 D/ACRA    ( 2488): onActivityStopped class org.jellyfin.androidtv.ui.browsing.MainActivity
08-07 09:45:24.927 D/ACRA    ( 2488): onActivitySaveInstanceState class org.jellyfin.androidtv.ui.browsing.MainActivity
08-07 09:45:35.253 I/org.jellyfin.sdk.api.sockets.OkHttpWebsocketSession( 2488): Sending (raw) message {"MessageType":"KeepAlive","Data":{}}
08-07 09:45:35.277 I/org.jellyfin.sdk.api.sockets.OkHttpWebsocketSession( 2488): Receiving (raw) message {"MessageType":"KeepAlive","MessageId":"1b8c97b1099548f9891a78c3a5721137"}
08-07 09:47:10.796 E/lyfin.androidt( 3095): Not starting debugger since process cannot load the jdwp agent.
08-07 09:47:11.118 W/lyfin.androidt( 3095): JIT profile information will not be recorded: profile file does not exist.
08-07 09:47:11.119 I/chatty  ( 3095): uid=10088(org.jellyfin.androidtv) identical 1 line
08-07 09:47:11.119 W/lyfin.androidt( 3095): JIT profile information will not be recorded: profile file does not exist.
08-07 09:47:11.125 D/NetworkSecurityConfig( 3095): No Network Security Config specified, using platform default
08-07 09:47:11.125 D/NetworkSecurityConfig( 3095): No Network Security Config specified, using platform default
08-07 09:47:11.206 D/ACRA    ( 3095): ACRA processName='org.jellyfin.androidtv'
08-07 09:47:11.209 I/ACRA    ( 3095): ACRA is enabled for org.jellyfin.androidtv, initializing...
08-07 09:47:11.209 D/ACRA    ( 3095): SimplePluginLoader loading services from plugin classes : [Ljava.lang.Class;@677d4c
08-07 09:47:11.209 D/ACRA    ( 3095): ServicePluginLoader loading services from ServiceLoader : java.util.ServiceLoader[org.acra.collector.Collector]
08-07 09:47:11.245 D/ACRA    ( 3095): Loaded Collector of type org.acra.collector.ConfigurationCollector
08-07 09:47:11.245 D/ACRA    ( 3095): Loaded Collector of type org.acra.collector.CustomDataCollector
08-07 09:47:11.246 D/ACRA    ( 3095): Loaded Collector of type org.acra.collector.DeviceFeaturesCollector
08-07 09:47:11.246 D/ACRA    ( 3095): Loaded Collector of type org.acra.collector.DeviceIdCollector
08-07 09:47:11.246 D/ACRA    ( 3095): Loaded Collector of type org.acra.collector.DisplayManagerCollector
08-07 09:47:11.246 D/ACRA    ( 3095): Loaded Collector of type org.acra.collector.DropBoxCollector
08-07 09:47:11.246 D/ACRA    ( 3095): Loaded Collector of type org.acra.collector.LogCatCollector
08-07 09:47:11.246 D/ACRA    ( 3095): Loaded Collector of type org.acra.collector.LogFileCollector
08-07 09:47:11.246 D/ACRA    ( 3095): Loaded Collector of type org.acra.collector.MediaCodecListCollector
08-07 09:47:11.246 D/ACRA    ( 3095): Loaded Collector of type org.acra.collector.MemoryInfoCollector
08-07 09:47:11.246 D/ACRA    ( 3095): Loaded Collector of type org.acra.collector.PackageManagerCollector
08-07 09:47:11.246 D/ACRA    ( 3095): Loaded Collector of type org.acra.collector.ReflectionCollector
08-07 09:47:11.247 D/ACRA    ( 3095): Loaded Collector of type org.acra.collector.SettingsCollector
08-07 09:47:11.247 D/ACRA    ( 3095): Loaded Collector of type org.acra.collector.SharedPreferencesCollector
08-07 09:47:11.247 D/ACRA    ( 3095): Loaded Collector of type org.acra.collector.SimpleValuesCollector
08-07 09:47:11.247 D/ACRA    ( 3095): Loaded Collector of type org.acra.collector.StacktraceCollector
08-07 09:47:11.247 D/ACRA    ( 3095): Loaded Collector of type org.acra.collector.ThreadCollector
08-07 09:47:11.282 D/ACRA    ( 3095): Loaded Collector of type org.acra.collector.TimeCollector
08-07 09:47:11.310 D/ACRA    ( 3095): SimplePluginLoader loading services from plugin classes : [Ljava.lang.Class;@677d4c
08-07 09:47:11.310 D/ACRA    ( 3095): ServicePluginLoader loading services from ServiceLoader : java.util.ServiceLoader[org.acra.scheduler.SenderSchedulerFactory]
08-07 09:47:11.310 D/ACRA    ( 3095): SimplePluginLoader loading services from plugin classes : [Ljava.lang.Class;@677d4c
08-07 09:47:11.310 D/ACRA    ( 3095): ServicePluginLoader loading services from ServiceLoader : java.util.ServiceLoader[org.acra.config.ReportingAdministrator]
08-07 09:47:11.318 W/lyfin.androidt( 3095): Accessing hidden method Landroid/graphics/ImageDecoder;->createSource([B)Landroid/graphics/ImageDecoder$Source; (greylist-max-o, linking, denied)
08-07 09:47:11.324 D/WM-WrkMgrInitializer( 3095): Initializing WorkManager with default configuration.
08-07 09:47:11.326 W/lyfin.androidt( 3095): Accessing hidden field Ljava/util/Collections$SynchronizedCollection;->mutex:Ljava/lang/Object; (greylist-max-o, reflection, denied)
08-07 09:47:11.326 W/lyfin.androidt( 3095): Accessing hidden method Ljava/util/Collections$SynchronizedSet;-><init>(Ljava/util/Set;Ljava/lang/Object;)V (greylist-max-o, reflection, denied)
08-07 09:47:11.326 W/lyfin.androidt( 3095): Accessing hidden method Ljava/util/Collections$SynchronizedCollection;-><init>(Ljava/util/Collection;Ljava/lang/Object;)V (greylist-max-o, reflection, denied)
08-07 09:47:11.327 I/TetheringManager( 3095): registerTetheringEventCallback:org.jellyfin.androidtv
08-07 09:47:11.350 I/LogInitializer( 3095): Debug tree planted
08-07 09:47:11.363 I/MigrationContext( 3095): Requested migration from 2 to 2. Found 1 migrations in total.
08-07 09:47:11.377 I/SessionRepositoryImpl( 3095): Restoring session
08-07 09:47:11.377 I/SessionRepositoryImpl( 3095): Destroying current session
08-07 09:47:11.379 D/ACRA    ( 3095): ACRA processName='org.jellyfin.androidtv'
08-07 09:47:11.406 I/MigrationContext( 3095): Requested migration from 7 to 7. Found 4 migrations in total.
08-07 09:47:11.407 I/ActivityThemeExtensionsKt( 3095): Applying theme DARK
08-07 09:47:11.410 D/ACRA    ( 3095): onActivityCreated class org.jellyfin.androidtv.ui.browsing.MainActivity
08-07 09:47:11.422 D/NavigationRepositoryImpl( 3095): Navigating to Fragment(fragment=class org.jellyfin.androidtv.ui.home.HomeFragment (Kotlin reflection is not available), arguments=Bundle[{}]) (via init)
08-07 09:47:11.424 D/LegacyMediaManager( 3095): Added event listener.  Total listeners: 1
08-07 09:47:11.425 W/MainActivity( 3095): Activity org.jellyfin.androidtv.ui.browsing.MainActivity started without a session, bouncing to StartupActivity
08-07 09:47:11.429 E/ACRA    ( 3095): ACRA caught a NullPointerException for org.jellyfin.androidtv
08-07 09:47:11.429 E/ACRA    ( 3095): java.lang.NullPointerException
08-07 09:47:11.429 E/ACRA    ( 3095):   at org.jellyfin.androidtv.ui.home.HomeFragmentHelper.loadResume(HomeFragmentHelper.kt:33)
08-07 09:47:11.429 E/ACRA    ( 3095):   at org.jellyfin.androidtv.ui.home.HomeFragmentHelper.loadResumeVideo(HomeFragmentHelper.kt:51)
08-07 09:47:11.429 E/ACRA    ( 3095):   at org.jellyfin.androidtv.ui.home.HomeRowsFragment$onCreate$1.invokeSuspend(HomeRowsFragment.kt:122)
08-07 09:47:11.429 E/ACRA    ( 3095):   at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
08-07 09:47:11.429 E/ACRA    ( 3095):   at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
08-07 09:47:11.429 E/ACRA    ( 3095):   at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:115)
08-07 09:47:11.429 E/ACRA    ( 3095):   at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:103)
08-07 09:47:11.429 E/ACRA    ( 3095):   at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
08-07 09:47:11.429 E/ACRA    ( 3095):   at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793)
08-07 09:47:11.429 E/ACRA    ( 3095):   at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697)
08-07 09:47:11.429 E/ACRA    ( 3095):   at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684)
08-07 09:47:11.429 E/ACRA    ( 3095):   Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@4c269fd, Dispatchers.IO]
08-07 09:47:11.429 D/ACRA    ( 3095): Building report
08-07 09:47:11.430 D/ACRA    ( 3095): Starting collectors with priority FIRST
08-07 09:47:11.431 D/ACRA    ( 3095): Calling collector org.acra.collector.LogCatCollector
08-07 09:47:11.431 D/ACRA    ( 3095): Calling collector org.acra.collector.DropBoxCollector
08-07 09:47:11.431 D/ACRA    ( 3095): Calling collector org.acra.collector.StacktraceCollector
08-07 09:47:11.431 D/ACRA    ( 3095): Collector org.acra.collector.DropBoxCollector completed
08-07 09:47:11.432 D/ACRA    ( 3095): Collector org.acra.collector.StacktraceCollector completed
08-07 09:47:11.446 D/ACRA    ( 3095): Retrieving logcat output (buffer:default)...
08-07 09:47:11.447 D/ACRA    ( 3095): SimplePluginLoader loading services from plugin classes : [Ljava.lang.Class;@677d4c
08-07 09:47:11.447 D/ACRA    ( 3095): ServicePluginLoader loading services from ServiceLoader : java.util.ServiceLoader[org.acra.startup.StartupProcessor]
08-07 09:47:11.448 D/ACRA    ( 3095): Loaded StartupProcessor of type org.acra.startup.UnapprovedStartupProcessor
08-07 09:47:11.459 I/ActivityThemeExtensionsKt( 3095): Applying theme DARK
08-07 09:47:11.459 D/ACRA    ( 3095): onActivityCreated class org.jellyfin.androidtv.ui.startup.StartupActivity
08-07 09:47:11.486 D/ACRA    ( 3095): onActivityStarted class org.jellyfin.androidtv.ui.startup.StartupActivity
08-07 09:47:11.504 D/ACRA    ( 3095): onActivityResumed class org.jellyfin.androidtv.ui.startup.StartupActivity
08-07 09:47:11.510 I/android_os_HwBinder( 3095): HwBinder: Starting thread pool for getting: vendor.nvidia.hardware.cpl.service_common@1.0::INvCplHalCommonService/default

App information

App version: 0.16.0-beta.2 (160002)
Package name: org.jellyfin.androidtv
Build:

{"BOARD":"sif","BOOTLOADER":"32.00.2019.50-t210-69ebfcbe","BRAND":"NVIDIA","CPU_ABI":"armeabi-v7a","CPU_ABI2":"armeabi","DEVICE":"sif","DISPLAY":"RQ1A.210105.003.7825199_3167.5736","FINGERPRINT":"NVIDIA\/sif\/sif:11\/RQ1A.210105.003\/7825199_3167.5736:user\/release-keys","HARDWARE":"sif","HOST":"mobile-u64-5306-d6000","ID":"RQ1A.210105.003","IS_DEBUGGABLE":false,"IS_EMULATOR":false,"MANUFACTURER":"NVIDIA","MODEL":"SHIELD Android TV","PERMISSIONS_REVIEW_REQUIRED":true,"PRODUCT":"sif","RADIO":"unknown","SUPPORTED_32_BIT_ABIS":["armeabi-v7a","armeabi"],"SUPPORTED_64_BIT_ABIS":[],"SUPPORTED_ABIS":["armeabi-v7a","armeabi"],"TAGS":"release-keys","TIME":1665975946000,"TYPE":"user","UNKNOWN":"unknown","USER":"NVIDIA","VERSION":{"ACTIVE_CODENAMES":[],"BASE_OS":"","CODENAME":"REL","INCREMENTAL":"7825199_3167.5736","PREVIEW_SDK_FINGERPRINT":"REL","PREVIEW_SDK_INT":0,"RELEASE":"11","RELEASE_OR_CODENAME":"11","SDK":"30","SDK_INT":30,"SECURITY_PATCH":"2022-04-05"}}

Build config:

{"APPLICATION_ID":"org.jellyfin.androidtv","BUILD_TYPE":"release","DEBUG":false,"DEVELOPMENT":false,"VERSION_CODE":160002,"VERSION_NAME":"0.16.0-beta.2"}

Device information

Android version: 11
Device brand: NVIDIA
Device product: sif
Device model: SHIELD Android TV

Crash information

Start time: 2023-08-07T09:47:11.310+02:00
Crash time: 2023-08-07T09:47:11.639+02:00

Application version

0.16.0-beta.2

Where did you install the app from?

Google Play

Device information

Shield TV

Android version

Android 11

Jellyfin server version

10.8.10

nielsvanvelzen commented 1 year ago

Do you by any chance have the option to always ask for credentials enabled in the preferences?

krutburken commented 1 year ago

Nope. "Automatic sign in" is disabled however, as there are multiple users using this particular device.

nielsvanvelzen commented 1 year ago

Ah right, I think the issue only occurs when either automatic sign in is disabled or always ask for credentials is enabled. Which is not the case by default so this crash doesn't occur for most users (including myself). I'll have a look and see what I can find 👍

nielsvanvelzen commented 1 year ago

I'm unfortunately unable to reproduce the issue making it hard to fix. Can you explain with more detail how you're able to trigger this crash?

krutburken commented 1 year ago

Tbh I can't reliably recreate it either, hence the "random" feeling of it. What generally seems to happen is that the app has been sitting idle for a while, and when you try to resume using the app, it crashes with this error. It is then followed by an instant crash with the same error when you try to open the app again from the homescreen. When you try to open the app a second time it works normally and you're directed to the screen where you select which user to switch to.

Not sure how helpful this is but I can see if I can get it to trigger more reliably.

krutburken commented 1 year ago

Okay so I did manage to get it to trigger once, by letting the device idle and go into sleep mode. When I then woke the device and started the jellyfin app, it crashed immediately with this error. Annoyingly I still can't get it to trigger reliably.

According to logs this error has occurred 7 times today alone, so it's quite frequent

krutburken commented 1 year ago

@nielsvanvelzen To reproduce: 1: Disable automatic sign-in in app settings 2: Start app and select a user in the "Who's watching?" screen (admin or normal user doesn't matter). There's three users added in the app I'm testing this on 3: When logged in and Jellyfin home is loaded, press the home button on your device 4: When on androidtv home screen, sleep the device 5: After the device has entered sleep mode, start device again. When now opening the Jellyfin app it will instantly crash with this error

The error gets triggered every single time I do this.

Edit: Can be reproduced the same way on a Google TV 4K

nielsvanvelzen commented 10 months ago

A fix for this will be included in 0.16.3. Unfortunately it doesn't fix all instances of the app crashing when re-opening it but most of them should be gone. If, with 0.16.3, the app still crashes for you please verify if the crash log is the same as the one in this issue (look for this line specifically at org.jellyfin.androidtv.ui.home.HomeFragmentHelper.loadResume(HomeFragmentHelper.kt:33))) or not. You can create a new issue with the crash logs and as much information as you can give us (like did you change app preferences like auto-login, what steps did you take to open and close the app, etc.)