moagrius / TileView

TileView is a subclass of android.view.ViewGroup that asynchronously displays, pans and zooms tile-based images. Plugins are available for features like markers, hotspots, and path drawing.
MIT License
1.46k stars 337 forks source link

App killed in background crashes when returning to foreground #535

Open AaronKTowne opened 5 years ago

AaronKTowne commented 5 years ago

Steps to reproduce:

  1. Put TileView in layout.
  2. Set layout as content view in Activity
  3. Background the app.
  4. Kill the process (either system or Terminate Application from logcat)
  5. Foreground the app.

Expected Results: Does not crash

Actual Results: App crashes. Stack dump below.

Note: This does appear to be from the save state from com.moagrius.widget.ScalingScrollView.

FATAL EXCEPTION: main Process: com.example, PID: 28646 android.os.BadParcelableException: ClassNotFoundException when unmarshalling: com.moagrius.widget.ScalingScrollView$ScrollScaleState at android.os.Parcel.readParcelableCreator(Parcel.java:2839) at android.os.Parcel.readParcelable(Parcel.java:2765) at android.view.AbsSavedState.<init>(AbsSavedState.java:67) at android.view.View$BaseSavedState.<init>(View.java:26247) at android.view.View$BaseSavedState.<init>(View.java:26236) at com.moagrius.widget.ScrollView$SavedState.<init>(ScrollView.java:991) at com.moagrius.widget.ScalingScrollView$ScrollScaleState.<init>(ScalingScrollView.java:330) at com.moagrius.widget.ScalingScrollView$ScrollScaleState$1.createFromParcel(ScalingScrollView.java:347) at com.moagrius.widget.ScalingScrollView$ScrollScaleState$1.createFromParcel(ScalingScrollView.java:345) at android.os.Parcel.readParcelable(Parcel.java:2774) at android.os.Parcel.readValue(Parcel.java:2668) at android.os.Parcel.readSparseArrayInternal(Parcel.java:3118) at android.os.Parcel.readSparseArray(Parcel.java:2351) at android.os.Parcel.readValue(Parcel.java:2725) at android.os.Parcel.readArrayMapInternal(Parcel.java:3037) at android.os.BaseBundle.initializeFromParcelLocked(BaseBundle.java:288) at android.os.BaseBundle.unparcel(BaseBundle.java:232) at android.os.Bundle.getSparseParcelableArray(Bundle.java:1010) at com.android.internal.policy.PhoneWindow.restoreHierarchyState(PhoneWindow.java:2133) at android.app.Activity.onRestoreInstanceState(Activity.java:1135) at android.app.Activity.performRestoreInstanceState(Activity.java:1090) at android.app.Instrumentation.callActivityOnRestoreInstanceState(Instrumentation.java:1317) at android.app.ActivityThread.handleStartActivity(ActivityThread.java:2991) at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:180) at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:165) at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:142) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1816) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6718) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

moagrius commented 5 years ago

nicely written ticket. so im putting a willfix label on this, but in reality it probably won't be until weekend after next unless i get lucky on some other things. if you have the time, i'd probably just nuke the ThreadPoolExecutor in a public destroy method, then ask the containing controller (activity or fragment) to clean up when it needs too. we could also run a service to do it onTaskRemoved. i mention this in case you feel like taking a shot and issuing a PR with a fix. it's open source after all. if not, i'll grab it as soon as i can.

thanks for filing this bug