More-Than-Solitaire / Tabs-Lite

An ad-free open source guitar tablature application using an existing popular tabs database. Built for speed and simplicity.
Apache License 2.0
64 stars 4 forks source link

Crash on changing dark mode status after visiting Popular tab when internet is off #59

Closed cullub closed 2 years ago

cullub commented 2 years ago

Steps to reproduce:

  1. Turn device internet off (wifi and data both)
  2. Close the app from recent apps (if applicable)
  3. Start the app
  4. Navigate to the Popular tab and then to a different tab
  5. Change Dark Mode status (if currently light, set dark; if currently dark, set light)

Expected outcome:

App changes and does not crash.

Actual outcome:

App changes briefly and then crashes.

Notes:

This happens only when internet is off. If internet is on for app launch, even if internet is turned off afterword, no crash is experienced. However, after re-launching the app, the new dark mode status works just fine.

Impact: 7 users, 20 occurrences

Crash log:

java.lang.IllegalArgumentException: 
  at com.google.android.material.snackbar.Snackbar.makeInternal (Snackbar.java:198)
  at com.google.android.material.snackbar.Snackbar.make (Snackbar.java:157)
  at com.gbros.tabslite.TopTabsFragment$subscribeUi$1$1.run (TopTabsFragment.kt:66)
  at android.os.Handler.handleCallback (Handler.java:938)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at android.os.Looper.loop (Looper.java:233)
  at android.app.ActivityThread.main (ActivityThread.java:8010)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:631)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:978)

Relevant code:

// TopTabsFragment.kt
topTabsJob.invokeOnCompletion { cause ->
    if(cause != null){
        //problems
        Log.w(javaClass.simpleName, "Error finding top tabs. GetTopTabs job returned non-null. " + cause.message, cause.cause)
        requireActivity().runOnUiThread {
            binding.hasHistory = adapter.itemCount > 0  // unless we already have items here, show the No Tabs Here message
            Handler().postDelayed({ binding.swipeRefresh.isRefreshing = false }, 700)
            view?.let { Snackbar.make(it, "You're not connected to the internet", Snackbar.LENGTH_SHORT).show() }  // this is line 66
        }
    } else {
        // [...]
cullub commented 2 years ago

I think this has something to do with trying to load popular songs. This doesn't happen when on the popular tab. Maybe changing dark mode status triggers a refresh of the popular tabs, and the view it chooses for the snackbar causes issues.