y20k / transistor

Transistor - Simple Radio App for Android
http://y20k.org/transistor/
MIT License
435 stars 122 forks source link

App crashes directly after startup #344

Open gabschne opened 3 years ago

gabschne commented 3 years ago

Describe the bug After the update to version 4.0.11 the app crashes 99% of the time on start up. (One time the app actually managed to start without crashing directly.) Also all of my saved radio stations were deleted.

To Reproduce Steps to reproduce the behavior:

  1. Start the app

Expected behavior The app shouldn't crash after the start.

Screenshots -

Device:

Additional context Here is the (truncated) stack trace:

h.a.b0: Fatal exception in coroutines machinery for DispatchedContinuation[Dispatchers.Default, Continuation at org.y20k.transistor.collection.CollectionViewModel$loadCollection$1$deferred$1.invokeSuspend(CollectionViewModel.kt)@b5c4287]. Please read KDoc to 'handleFatalException' method and report this incident to maintainers at h.a.h0.f(SourceFile:4) at h.a.h0.run(SourceFile:23) at h.a.v1.a.i(SourceFile:1) at h.a.v1.a$a.run(SourceFile:11) Caused by: java.lang.StackOverflowError: stack size 1037KB at h.a.m1.toString(Unknown Source:0) at java.lang.String.valueOf(String.java:2827) at java.lang.StringBuilder.append(StringBuilder.java:132) at h.a.k0.toString(SourceFile:1) at java.lang.String.valueOf(String.java:2827) at java.lang.StringBuilder.append(StringBuilder.java:132) at h.a.q.toString(Unknown Source:18) at java.lang.String.valueOf(String.java:2827) at java.lang.StringBuilder.append(StringBuilder.java:132) at h.a.h.toString(SourceFile:3) at java.lang.String.valueOf(String.java:2827) at java.lang.StringBuilder.append(StringBuilder.java:132) at h.a.m1.toString(SourceFile:1) at java.lang.String.valueOf(String.java:2827) at java.lang.StringBuilder.append(StringBuilder.java:132) at h.a.k0.toString(SourceFile:1) at java.lang.String.valueOf(String.java:2827) at java.lang.StringBuilder.append(StringBuilder.java:132) [...] at h.a.d1.v(SourceFile:8) at h.a.d1.R(SourceFile:9) at h.a.d1.G(SourceFile:2) at h.a.b.j(SourceFile:2) at l.k.k.a.a.j(SourceFile:9) at h.a.h0.run(SourceFile:15) ... 2 more

y20k commented 3 years ago

@gabschne I am not 100% sure. The error message seems indicate that the JSON file that stores the collection of radio stations is broken. /Android/data/org.y20k.transistor/files/Collection/collection.json You may need to remove/rename that file to get Transistor to start correctly.

I am super sorry that your stations are lost. I will try to find out what happened here. I you know of any other steps to recreate the problem, please let me know. I will publish a new version of Transistor today. That one fixes another serious bug, but that seems to be unrelated.

gabschne commented 3 years ago

Oh I'm sorry, I forgot to mention in the bug description, that I've already tried to delete or reset all of the data with the help of the the standard Android app settings, because I thought it would help, too. But I also just double checked and there is no collection.json exisiting at all. (But the app still crashes.)

Don't worry about the deleted radio stations. To be honest, I didn't check the file before manually deleting all the app data, so it could be that the radio stations were not deleted, but just not displayed before the app crashed.

I'm afraid, there're really no steps I could provide to reproduce the problem, it just started to happen after the update to v. 4.0.11 so it might be a regression or something.

Edit: I just downgraded to v. 4.0.10 and the app works again.

y20k commented 3 years ago

Hi @gabschne

Thanks for providing more information. I am really puzzled, because I am not able to get the crash on any of my devices. And your description to reproduce it is super simple:

  1. Install v4.0.11+
  2. Open App
  3. Crash

I wonder if we oversaw something here.

gabschne commented 3 years ago

Is there maybe a debug version of the app available that outputs detailed logs or that uses (better) source maps for the stack trace? The one I posted in my description looks a bit obfuscated to me.

y20k commented 3 years ago

Here is a test APK where obfuscation and minifying is disabled.

It would be great, if you post your findings!! 👍

gabschne commented 3 years ago

Thank you!

Here's the output from logcat:

--------- beginning of crash 03-19 18:03:21.912 2615 2654 E AndroidRuntime: FATAL EXCEPTION: DefaultDispatcher-worker-2 03-19 18:03:21.912 2615 2654 E AndroidRuntime: Process: org.y20k.transistor, PID: 2615 03-19 18:03:21.912 2615 2654 E AndroidRuntime: kotlinx.coroutines.CoroutinesInternalError: Fatal exception in coroutines machinery for DispatchedContinuation[Dispatchers.Default, Continuation at org.y20k.transistor.collection.CollectionViewModel$loadCollection$1$deferred$1.invokeSuspend(CollectionViewModel.kt:91)@9f64a7]. Please read KDoc to 'handleFatalException' method and report this incident to maintainers 03-19 18:03:21.912 2615 2654 E AndroidRuntime: at kotlinx.coroutines.DispatchedTask.handleFatalException$kotlinx_coroutines_core(DispatchedTask.kt:144) 03-19 18:03:21.912 2615 2654 E AndroidRuntime: at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:115) 03-19 18:03:21.912 2615 2654 E AndroidRuntime: at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571) 03-19 18:03:21.912 2615 2654 E AndroidRuntime: at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:738) 03-19 18:03:21.912 2615 2654 E AndroidRuntime: at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678) 03-19 18:03:21.912 2615 2654 E AndroidRuntime: at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665) 03-19 18:03:21.912 2615 2654 E AndroidRuntime: Caused by: java.lang.StackOverflowError: stack size 1037KB 03-19 18:03:21.912 2615 2654 E AndroidRuntime: at kotlinx.coroutines.MainCoroutineDispatcher.toStringInternalImpl(MainCoroutineDispatcher.kt:61) 03-19 18:03:21.912 2615 2654 E AndroidRuntime: at kotlinx.coroutines.android.HandlerContext.toString(HandlerDispatcher.kt:152) 03-19 18:03:21.912 2615 2654 E AndroidRuntime: at java.lang.String.valueOf(String.java:2827) 03-19 18:03:21.912 2615 2654 E AndroidRuntime: at java.lang.StringBuilder.append(StringBuilder.java:132) 03-19 18:03:21.912 2615 2654 E AndroidRuntime: at kotlinx.coroutines.internal.DispatchedContinuation.toString(DispatchedContinuation.kt:251) 03-19 18:03:21.912 2615 2654 E AndroidRuntime: at kotlinx.coroutines.DebugStringsKt.toDebugString(DebugStrings.kt:16) 03-19 18:03:21.912 2615 2654 E AndroidRuntime: at kotlinx.coroutines.CancellableContinuationImpl.toString(CancellableContinuationImpl.kt:506) 03-19 18:03:21.912 2615 2654 E AndroidRuntime: at java.lang.String.valueOf(String.java:2827) 03-19 18:03:21.912 2615 2654 E AndroidRuntime: at java.lang.StringBuilder.append(StringBuilder.java:132) 03-19 18:03:21.912 2615 2654 E AndroidRuntime: at kotlinx.coroutines.ResumeAwaitOnCompletion.toString(JobSupport.kt:1414) 03-19 18:03:21.912 2615 2654 E AndroidRuntime: at java.lang.String.valueOf(String.java:2827) 03-19 18:03:21.912 2615 2654 E AndroidRuntime: at java.lang.StringBuilder.append(StringBuilder.java:132) 03-19 18:03:21.912 2615 2654 E AndroidRuntime: at kotlinx.coroutines.DisposeOnCancel.toString(CancellableContinuation.kt:385) 03-19 18:03:21.912 2615 2654 E AndroidRuntime: at java.lang.String.valueOf(String.java:2827) 03-19 18:03:21.912 2615 2654 E AndroidRuntime: at java.lang.StringBuilder.append(StringBuilder.java:132) 03-19 18:03:21.912 2615 2654 E AndroidRuntime: at kotlinx.coroutines.CompletedContinuation.toString(Unknown Source:25) 03-19 18:03:21.912 2615 2654 E AndroidRuntime: at java.lang.String.valueOf(String.java:2827) 03-19 18:03:21.912 2615 2654 E AndroidRuntime: at java.lang.StringBuilder.append(StringBuilder.java:132) 03-19 18:03:21.912 2615 2654 E AndroidRuntime: at kotlinx.coroutines.CancellableContinuationImpl.toString(CancellableContinuationImpl.kt:506) 03-19 18:03:21.912 2615 2654 E AndroidRuntime: at java.lang.String.valueOf(String.java:2827) 03-19 18:03:21.912 2615 2654 E AndroidRuntime: at java.lang.StringBuilder.append(StringBuilder.java:132) 03-19 18:03:21.912 2615 2654 E AndroidRuntime: at kotlinx.coroutines.ResumeAwaitOnCompletion.toString(JobSupport.kt:1414) 03-19 18:03:21.912 2615 2654 E AndroidRuntime: at java.lang.String.valueOf(String.java:2827) 03-19 18:03:21.912 2615 2654 E AndroidRuntime: at java.lang.StringBuilder.append(StringBuilder.java:132) 03-19 18:03:21.912 2615 2654 E AndroidRuntime: at kotlinx.coroutines.DisposeOnCancel.toString(CancellableContinuation.kt:385) 03-19 18:03:21.912 2615 2654 E AndroidRuntime: at java.lang.String.valueOf(String.java:2827) 03-19 18:03:21.912 2615 2654 E AndroidRuntime: at java.lang.StringBuilder.append(StringBuilder.java:132) 03-19 18:03:21.912 2615 2654 E AndroidRuntime: at kotlinx.coroutines.CompletedContinuation.toString(Unknown Source:25) 03-19 18:03:21.912 2615 2654 E AndroidRuntime: at java.lang.String.valueOf(String.java:2827) 03-19 18:03:21.912 2615 2654 E AndroidRuntime: at java.lang.StringBuilder.append(StringBuilder.java:132) 03-19 18:03:21.912 2615 2654 E AndroidRuntime: at kotlinx.coroutines.CancellableContinuationImpl.toString(CancellableContinuationImpl.kt:506) 03-19 18:03:21.912 2615 2654 E AndroidRuntime: at java.lang.String.valueOf(String.java:2827) 03-19 18:03:21.912 2615 2654 E AndroidRuntime: at java.lang.StringBuilder.append(StringBuilder.java:132) 03-19 18:03:21.912 2615 2654 E AndroidRuntime: at kotlinx.coroutines.ResumeAwaitOnCompletion.toString(JobSupport.kt:1414) 03-19 18:03:21.912 2615 2654 E AndroidRuntime: at java.lang.String.valueOf(String.java:2827) 03-19 18:03:21.912 2615 2654 E AndroidRuntime: at java.lang.StringBuilder.append(StringBuilder.java:132) 03-19 18:03:21.912 2615 2654 E AndroidRuntime: at kotlinx.coroutines.DisposeOnCancel.toString(CancellableContinuation.kt:385) 03-19 18:03:21.912 2615 2654 E AndroidRuntime: at java.lang.String.valueOf(String.java:2827) 03-19 18:03:21.912 2615 2654 E AndroidRuntime: at java.lang.StringBuilder.append(StringBuilder.java:132) 03-19 18:03:21.912 2615 2654 E AndroidRuntime: at kotlinx.coroutines.CompletedContinuation.toString(Unknown Source:25) 03-19 18:03:21.912 2615 2654 E AndroidRuntime: at java.lang.String.valueOf(String.java:2827) [...] 03-19 18:03:21.928 2615 2654 E AndroidRuntime: at java.lang.StringBuilder.append(StringBuilder.java:132) 03-19 18:03:21.928 2615 2654 E AndroidRuntime: at kotlinx.coroutines.CancellableContinuationImpl.toString(CancellableContinuationImpl.kt:506) 03-19 18:03:21.928 2615 2654 E AndroidRuntime: at java.lang.String.valueOf(String.java:2827) 03-19 18:03:21.928 2615 2654 E AndroidRuntime: at java.lang.StringBuilder.append(StringBuilder.java:132) 03-19 18:03:21.928 2615 2654 E AndroidRuntime: at kotlinx.coroutines.ResumeAwaitOnCompletion.toString(JobSupport.kt:1414) 03-19 18:03:21.928 2615 2654 E AndroidRuntime: at java.lang.String.valueOf(String.java:2827) 03-19 18:03:21.928 2615 2654 E AndroidRuntime: at java.lang.StringBuilder.append(StringBuilder.java:132) 03-19 18:03:21.928 2615 2654 E AndroidRuntime: at kotlinx.coroutines.JobSupport.completeStateFinalization(JobSupport.kt:320) 03-19 18:03:21.928 2615 2654 E AndroidRuntime: at kotlinx.coroutines.JobSupport.tryMakeCompleting(JobSupport.kt:853) 03-19 18:03:21.928 2615 2654 E AndroidRuntime: at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:111) 03-19 18:03:21.928 2615 2654 E AndroidRuntime: at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)

This happens more or less right before the crash:

03-19 18:03:21.827 2615 2615 W transistor_DateTimeHelper: Unable to parse. Trying an alternative Date format. java.text.ParseException: Unparseable date: "" 03-19 18:03:21.827 2615 2615 W transistor_DateTimeHelper: Unable to parse. Trying an alternative Date format. java.text.ParseException: Unparseable date: "" 03-19 18:03:21.828 2615 2615 E transistor_DateTimeHelper: Unable to parse. Returning a default date. java.text.ParseException: Unparseable date: ""

But this looks like caught and handled to me, if I'm interpreting the log correctly.

y20k commented 3 years ago

I must say, that I am still a bit lost here, even after reading the new Logcat.

I pushed some minor changes to the app yesterday and today. Both could probably be related to the error. But I was just guessing and searching the internet for related errors.

I compiled a fresh test apk. Does the app still crash on your device?

Note: This is again a normal apk with obfuscation and minifying activated - just like a normal release would be.

gabschne commented 3 years ago

Yeah, I had already looked into the corresponding file earlier, and as you had already written or the stack trace says, the collection is read in the reported line. However, according to git blame, nothing big seems to have changed between 4.0.10 and 4.0.11 at this section of the code. Very strange.

But some good news: The new version does NOT crash anymore, so one of the minor changes seems to have fixed the problem. If there were several and you are interested in which one exactly or debugging it, feel free to upload different versions of the app and I'll test them one by one.