ArnyminerZ / icsx5

ICSx⁵ is an Android app to subscribe to remote or local iCalendar files (like time tables of your school/university or event files of your sports team).
https://icsx5.bitfire.at
GNU General Public License v3.0
2 stars 0 forks source link

Adding subscription in standardDebug flavor crashes the app #85

Closed sunkup closed 9 months ago

sunkup commented 9 months ago

Steps to reproduce:

Stacktrace:

11:29:52.087  I  Skipped 91 frames!  The application may be doing too much work on its main thread.
11:29:52.146  I  Davey! duration=1576ms; Flags=0, IntendedVsync=53615313264, Vsync=55131979870, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=55136351948, AnimationStart=55136366615, PerformTraversalsStart=55179730518, DrawStart=55185661148, SyncQueued=55189217970, SyncStart=55193292850, IssueDrawCommandsStart=55193346596, SwapBuffers=55193860880, FrameCompleted=55195833381, DequeueBufferDuration=62642, QueueBufferDuration=262262, GpuCompleted=8093905350535893128, 
11:29:52.323  I  Davey! duration=1757ms; Flags=0, IntendedVsync=53615313264, Vsync=55131979870, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=55136351948, AnimationStart=55136366615, PerformTraversalsStart=55179730518, DrawStart=55355912814, SyncQueued=55369671804, SyncStart=55370231031, IssueDrawCommandsStart=55370288089, SwapBuffers=55372141856, FrameCompleted=55373077382, DequeueBufferDuration=43547, QueueBufferDuration=196211, GpuCompleted=8093905350535893128, 
11:29:55.783  D  Installing profile for at.bitfire.icsdroid
11:30:00.799  D  endAllActiveAnimators on 0xe6bcb1b0 (RippleDrawable) with handle 0xb9830250
11:30:13.560  I  Validation result updated: null
11:30:13.570  I  Skipped 37 frames!  The application may be doing too much work on its main thread.
11:30:14.865  D  Owner FocusChanged(true)
11:30:18.943  E  Destroying unexpected ActionMode instance of TYPE_FLOATING; com.android.internal.view.FloatingActionMode@467ff94 was not the current floating action mode! Expected null
11:30:19.130  I  https://www.feiertage-deutschland.de/kalender-download/ics/schulferien-niedersachsen.ics
11:30:19.276  D  endAllActiveAnimators on 0xe6bce810 (RippleDrawable) with handle 0xb983af10
11:30:20.148  E  Couldn't create calendar
                 java.lang.NullPointerException
                    at at.bitfire.icsdroid.model.CreateSubscriptionModel$create$1.invokeSuspend(CreateSubscriptionModel.kt:38)
                    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)
11:30:20.163  D  Compat change id reported: 147798919; UID 10156; state: ENABLED
--------- beginning of crash
11:30:20.165  D  Shutting down VM
11:30:20.176  E  FATAL EXCEPTION: main
                 Process: at.bitfire.icsdroid, PID: 4751
                 java.lang.IllegalStateException: You must either set a text or a view
                    at com.android.internal.util.Preconditions.checkState(Preconditions.java:173)
                    at android.widget.Toast.show(Toast.java:188)
                    at at.bitfire.icsdroid.ui.AddCalendarActivity$onCreate$3.invoke(AddCalendarActivity.kt:117)
                    at at.bitfire.icsdroid.ui.AddCalendarActivity$onCreate$3.invoke(AddCalendarActivity.kt:116)
                    at at.bitfire.icsdroid.ui.AddCalendarActivity$sam$androidx_lifecycle_Observer$0.onChanged(Unknown Source:2)
                    at androidx.lifecycle.LiveData.considerNotify(LiveData.java:133)
                    at androidx.lifecycle.LiveData.dispatchingValue(LiveData.java:151)
                    at androidx.lifecycle.LiveData.setValue(LiveData.java:309)
                    at androidx.lifecycle.MutableLiveData.setValue(MutableLiveData.java:50)
                    at androidx.lifecycle.LiveData$1.run(LiveData.java:93)
                    at android.os.Handler.handleCallback(Handler.java:938)
                    at android.os.Handler.dispatchMessage(Handler.java:99)
                    at android.os.Looper.loop(Looper.java:223)
                    at android.app.ActivityThread.main(ActivityThread.java:7656)
                    at java.lang.reflect.Method.invoke(Native Method)
                    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
ArnyminerZ commented 9 months ago

I think this only happens when the link is valid, but there's an error when adding it. Maybe during the synchronization?

I think the issue comes from the errorMessage definition:

val errorMessage = MutableLiveData<String>()

We are not making it nullable, so Kotlin thinks that it's always unset or not null. But then, we set the value to Exception.localizedMessage, which can be null sometimes: errorMessage.postValue(e.localizedMessage).

I'd make errorMessage nullable, as well as extending the value post to this, to give more info just in case:

val errorMessage = MutableLiveData<String?>(null)
...
errorMessage.postValue(e.localizedMessage ?: e.message)