michael-rapp / ChromeLikeTabSwitcher

Provides a tab switcher similar to the one, which is used in Google Chrome on Android
Apache License 2.0
1.23k stars 140 forks source link

Crash when dragging-to-dismiss a tab and opening app switcher. #23

Open dbrant opened 5 years ago

dbrant commented 5 years ago

Another crash in the series of "state save" issues: To reproduce, start dragging to dismiss the topmost tab, drag it past the 50% mark, and while still holding the tab, invoke the system app switcher.

febd97be246f

Stack trace:

java.lang.ArrayIndexOutOfBoundsException: length=10; index=-1
        at java.util.ArrayList.get(ArrayList.java:439)
        at de.mrapp.android.tabswitcher.model.TabSwitcherModel.getTab(TabSwitcherModel.java:1156)
        at de.mrapp.android.tabswitcher.TabSwitcher.getTab(TabSwitcher.java:1503)
        at de.mrapp.android.tabswitcher.model.TabItem.create(TabItem.java:99)
        at de.mrapp.android.tabswitcher.layout.phone.PhoneTabSwitcherLayout.onTabRemoved(PhoneTabSwitcherLayout.java:3251)
        at de.mrapp.android.tabswitcher.model.TabSwitcherModel.notifyOnTabRemoved(TabSwitcherModel.java:651)
        at de.mrapp.android.tabswitcher.model.TabSwitcherModel.removeTab(TabSwitcherModel.java:1291)
        at de.mrapp.android.tabswitcher.layout.phone.PhoneTabSwitcherLayout.onSwipeEnded(PhoneTabSwitcherLayout.java:3402)
        at de.mrapp.android.tabswitcher.layout.AbstractDragTabsEventHandler.notifyOnSwipeEnded(AbstractDragTabsEventHandler.java:456)
        at de.mrapp.android.tabswitcher.layout.AbstractDragTabsEventHandler.onUp(AbstractDragTabsEventHandler.java:751)
        at de.mrapp.android.tabswitcher.gesture.TouchEventDispatcher.removeEventHandler(TouchEventDispatcher.java:253)
        at de.mrapp.android.tabswitcher.layout.AbstractTabSwitcherLayout.detachLayout(AbstractTabSwitcherLayout.java:1429)
        at de.mrapp.android.tabswitcher.TabSwitcher.onSaveInstanceState(TabSwitcher.java:1974)
        at android.view.View.dispatchSaveInstanceState(View.java:17614)
        at android.view.ViewGroup.dispatchSaveInstanceState(ViewGroup.java:3720)
        at android.view.ViewGroup.dispatchSaveInstanceState(ViewGroup.java:3726)
        at android.view.ViewGroup.dispatchSaveInstanceState(ViewGroup.java:3726)
        at android.view.ViewGroup.dispatchSaveInstanceState(ViewGroup.java:3726)
        at android.view.ViewGroup.dispatchSaveInstanceState(ViewGroup.java:3726)
        at android.view.View.saveHierarchyState(View.java:17597)
        at com.android.internal.policy.PhoneWindow.saveHierarchyState(PhoneWindow.java:2096)
        at android.app.Activity.onSaveInstanceState(Activity.java:1566)
        at androidx.core.app.ComponentActivity.onSaveInstanceState(ComponentActivity.java:83)
        at androidx.fragment.app.FragmentActivity.onSaveInstanceState(FragmentActivity.java:589)
        at androidx.appcompat.app.AppCompatActivity.onSaveInstanceState(AppCompatActivity.java:510)
        at android.app.Activity.performSaveInstanceState(Activity.java:1496)
        at android.app.Instrumentation.callActivityOnSaveInstanceState(Instrumentation.java:1386)
        at android.app.ActivityThread.callCallActivityOnSaveInstanceState(ActivityThread.java:4721)
        at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:4025)
        at android.app.ActivityThread.handleStopActivity(ActivityThread.java:4084)
        at android.app.ActivityThread.-wrap24(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1622)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6494)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
dbrant commented 5 years ago

...and when dragging a non-topmost tab, then invoking the app switcher, the stack trace looks like this:

java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.ViewGroup$LayoutParams android.view.ViewGroup.getLayoutParams()' on a null object reference
        at de.mrapp.android.tabswitcher.layout.phone.PhoneArithmetics.getTabContainerSize(PhoneArithmetics.java:201)
        at de.mrapp.android.tabswitcher.layout.phone.PhoneTabSwitcherLayout.calculateSwipePosition(PhoneTabSwitcherLayout.java:377)
        at de.mrapp.android.tabswitcher.layout.phone.PhoneTabSwitcherLayout.animateSwipe(PhoneTabSwitcherLayout.java:898)
        at de.mrapp.android.tabswitcher.layout.phone.PhoneTabSwitcherLayout.animateRemove(PhoneTabSwitcherLayout.java:976)
        at de.mrapp.android.tabswitcher.layout.phone.PhoneTabSwitcherLayout.access$1000(PhoneTabSwitcherLayout.java:79)
        at de.mrapp.android.tabswitcher.layout.phone.PhoneTabSwitcherLayout$5.onGlobalLayout(PhoneTabSwitcherLayout.java:1288)
        at de.mrapp.android.tabswitcher.layout.phone.PhoneTabSwitcherLayout$13.onGlobalLayout(PhoneTabSwitcherLayout.java:1632)
        at de.mrapp.android.tabswitcher.layout.AbstractTabSwitcherLayout$LayoutListenerWrapper.onGlobalLayout(AbstractTabSwitcherLayout.java:134)
        at android.view.ViewTreeObserver.dispatchOnGlobalLayout(ViewTreeObserver.java:945)
        at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2250)
        at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1392)
        at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6752)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911)
        at android.view.Choreographer.doCallbacks(Choreographer.java:723)
        at android.view.Choreographer.doFrame(Choreographer.java:658)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
        at android.os.Handler.handleCallback(Handler.java:790)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6494)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

e8b1015edfe5

michael-rapp commented 5 years ago

Unfortunately, I wasn't able to reproduce this issue so far...