Page MenuHomePhabricator

App crashes when changing orientation or language with text highlighted
Closed, ResolvedPublic

Description

  1. Go to the Simon & Garfunkel article.
  2. Long press on "Garfunkel" in the title.
  3. Change the configuration (rotate the device to a new orientation or go to system language settings and change the language, then return to the app.)

Logcat:

         E  org.wikipedia.dev fatal error : Attempt to invoke virtual method 'org.wikipedia.page.PageProperties org.wikipedia.page.Page.getPageProperties()' on a null object reference
         E  java.lang.NullPointerException: Attempt to invoke virtual method 'org.wikipedia.page.PageProperties org.wikipedia.page.Page.getPageProperties()' on a null object reference
         E      at org.wikipedia.page.snippet.ShareHandler.createFunnel(ShareHandler.java:53)
         E      at org.wikipedia.page.snippet.ShareHandler.onTextSelected(ShareHandler.java:197)
         E      at org.wikipedia.page.PageViewFragmentInternal.onActionModeShown(PageViewFragmentInternal.java:568)
         E      at org.wikipedia.page.PageActivity.onSupportActionModeStarted(PageActivity.java:850)
         E      at android.support.v7.app.AppCompatDelegateImplV7.startSupportActionModeFromWindow(AppCompatDelegateImplV7.java:680)
         E      at android.support.v7.app.AppCompatDelegateImplV7.startSupportActionMode(AppCompatDelegateImplV7.java:574)
         E      at android.support.v7.app.AppCompatDelegateImplV14$AppCompatWindowCallbackV14.startAsSupportActionMode(AppCompatDelegateImplV14.java:74)
         E      at android.support.v7.app.AppCompatDelegateImplV14$AppCompatWindowCallbackV14.onWindowStartingActionMode(AppCompatDelegateImplV14.java:58)
         E      at android.support.v7.internal.view.WindowCallbackWrapper.onWindowStartingActionMode(WindowCallbackWrapper.java:139)
         E      at com.android.internal.policy.impl.PhoneWindow$DecorView.startActionMode(PhoneWindow.java:2955)
         E      at com.android.internal.policy.impl.PhoneWindow$DecorView.startActionModeForChild(PhoneWindow.java:2942)
         E      at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:701)
         E      at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:701)
         E      at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:701)
         E      at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:701)
         E      at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:701)
         E      at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:701)
         E      at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:701)
         E      at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:701)
         E      at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:701)
         E      at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:701)
         E      at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:701)
         E      at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:701)
         E      at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:701)
         E      at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:701)
         E      at android.view.View.startActionMode(View.java:4882)
         E      at android.widget.Editor.startSelectionActionMode(Editor.java:1558)
         E      at android.widget.TextView.onPreDraw(TextView.java:4956)
         E      at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:944)
         E      at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1970)
         E      at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1061)
         E      at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5891)
         E      at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
         E      at android.view.Choreographer.doCallbacks(Choreographer.java:580)
         E      at android.view.Choreographer.doFrame(Choreographer.java:550)
         E      at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
         E      at android.os.Handler.handleCallback(Handler.java:739)
         E      at android.os.Handler.dispatchMessage(Handler.java:95)
         E      at android.os.Looper.loop(Looper.java:135)
         E      at android.app.ActivityThread.main(ActivityThread.java:5293)
         E      at java.lang.reflect.Method.invoke(Native Method)
         E      at java.lang.reflect.Method.invoke(Method.java:372)
         E      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
         E      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:699)
         I  Finishing the last Activity prior to killing the Process
         I  Finished class org.wikipedia.page.PageActivity
Process  I  Sending signal. PID: 2729 SIG: 9

Details

Related Gerrit Patches:
apps/android/wikipedia : masterFix crash when rotating with highlighted text.

Event Timeline

Niedzielski raised the priority of this task from to Needs Triage.
Niedzielski updated the task description. (Show Details)
Niedzielski added a subscriber: Niedzielski.
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJun 19 2015, 4:01 AM

Hi @Niedzielski. Please associate at least one project with this task, otherwise nobody can find this task when searching in the corresponding project(s). Thanks.

TTO added a subscriber: TTO.

Looks like the Wikipedia Android app.

Dbrant triaged this task as High priority.Jun 19 2015, 1:40 PM
Dbrant moved this task from Needs Triage to Bug Backlog on the Wikipedia-Android-App-Backlog board.

Hi @Niedzielski. Please associate at least one project with this task, otherwise nobody can find this task when searching in the corresponding project(s). Thanks.

@Aklapper, sorry! I knew better but wasn't thinking when I filed this.

Niedzielski renamed this task from App crashes when changing language with text highlighted to App crashes when changing orientation or language with text highlighted.Jun 28 2015, 1:30 AM
Niedzielski updated the task description. (Show Details)
Niedzielski set Security to None.

Change 221824 had a related patch set uploaded (by Dbrant):
Fix crash when rotating with highlighted text.

https://gerrit.wikimedia.org/r/221824

Change 221824 merged by jenkins-bot:
Fix crash when rotating with highlighted text.

https://gerrit.wikimedia.org/r/221824

It's still failing - with two different errors. The steps are little vague though, but all include

  • highlight some text
  • rotate the device
  • invoke the left side menu
USER_COMMENT=highlight and rotate
ANDROID_VERSION=4.0.4
APP_VERSION_NAME=2.0.105-alpha-2015-06-30
BRAND=samsung
PHONE_MODEL=GT-P7510
CUSTOM_DATA=api = en.m.wikipedia.org
title = SpaceX CRS-7

STACK_TRACE=java.lang.RuntimeException: Unable to pause activity {org.wikipedia.alpha/org.wikipedia.page.PageActivity}: java.lang.ArrayIndexOutOfBoundsException: length=0; index=-1
at android.app.ActivityThread.performPauseActivity(ActivityThread.java:2718)
at android.app.ActivityThread.performPauseActivity(ActivityThread.java:2674)
at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:2652)
at android.app.ActivityThread.access$800(ActivityThread.java:127)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1166)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4507)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:978)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:745)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ArrayIndexOutOfBoundsException: length=0; index=-1
at java.util.ArrayList.get(ArrayList.java:306)
at org.wikipedia.page.PageViewFragmentInternal.getCurrentTab(PageViewFragmentInternal.java:434)
at org.wikipedia.page.PageViewFragmentInternal.onActivityCreated(PageViewFragmentInternal.java:343)
at android.support.v4.app.Fragment.performActivityCreated(Fragment.java:1797)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:979)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1138)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1120)
at android.support.v4.app.FragmentManagerImpl.dispatchPause(FragmentManager.java:1943)
at android.support.v4.app.FragmentActivity.onPause(FragmentActivity.java:393)
at org.wikipedia.page.PageActivity.onPause(PageActivity.java:782)
at android.app.Activity.performPause(Activity.java:4567)
at android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1198)
at android.app.ActivityThread.performPauseActivity(ActivityThread.java:2705)
... 12 more
java.lang.ArrayIndexOutOfBoundsException: length=0; index=-1
at java.util.ArrayList.get(ArrayList.java:306)
at org.wikipedia.page.PageViewFragmentInternal.getCurrentTab(PageViewFragmentInternal.java:434)
at org.wikipedia.page.PageViewFragmentInternal.onActivityCreated(PageViewFragmentInternal.java:343)
at android.support.v4.app.Fragment.performActivityCreated(Fragment.java:1797)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:979)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1138)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1120)
at android.support.v4.app.FragmentManagerImpl.dispatchPause(FragmentManager.java:1943)
at android.support.v4.app.FragmentActivity.onPause(FragmentActivity.java:393)
at org.wikipedia.page.PageActivity.onPause(PageActivity.java:782)
at android.app.Activity.performPause(Activity.java:4567)
at android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1198)
at android.app.ActivityThread.performPauseActivity(ActivityThread.java:2705)
at android.app.ActivityThread.performPauseActivity(ActivityThread.java:2674)
at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:2652)
at android.app.ActivityThread.access$800(ActivityThread.java:127)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1166)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4507)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:978)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:745)
at dalvik.system.NativeStart.main(Native Method)
USER_COMMENT=rotate after highlighting and then slide to the left menu and press today
ANDROID_VERSION=4.0.4
APP_VERSION_NAME=2.0.105-beta-2015-06-30
BRAND=samsung
PHONE_MODEL=GT-P7510
CUSTOM_DATA=api = en.m.wikipedia.org
title = Main Page

STACK_TRACE=java.lang.ArrayIndexOutOfBoundsException: length=0; index=-1
at java.util.ArrayList.get(ArrayList.java:306)
at org.wikipedia.page.PageViewFragmentInternal.getCurrentTab(PageViewFragmentInternal.java:434)
at org.wikipedia.page.PageViewFragmentInternal.onActivityCreated(PageViewFragmentInternal.java:343)
at android.support.v4.app.Fragment.performActivityCreated(Fragment.java:1797)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:979)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1138)
at android.support.v4.app.BackStackRecord.popFromBackStack(BackStackRecord.java:960)
at android.support.v4.app.FragmentManagerImpl.popBackStackState(FragmentManager.java:1553)
at android.support.v4.app.FragmentManagerImpl.popBackStackImmediate(FragmentManager.java:506)
at org.wikipedia.page.PageActivity.resetFragments(PageActivity.java:467)
at org.wikipedia.page.PageActivity.displayNewPage(PageActivity.java:562)
at org.wikipedia.page.PageActivity.displayMainPage(PageActivity.java:602)
at org.wikipedia.page.PageActivity.displayMainPage(PageActivity.java:591)
at org.wikipedia.NavDrawerFragment.onClick(NavDrawerFragment.java:179)
at android.view.View.performClick(View.java:3620)
at android.view.View$PerformClick.run(View.java:14322)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4507)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:978)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:745)
at dalvik.system.NativeStart.main(Native Method)
bearND added a subscriber: bearND.Jul 3 2015, 4:33 AM

@Etonkovidova I have a hard time reproducing this. Any more hints?

@Dbrant Based on the stack trace and based on

public Tab getCurrentTab() {
    return tabList.get(tabList.size() - 1);
}

it looks like tabList is empty.
The only idea I have right now to avoid an empty tabList is to move adding of tabs from onActivityCreated on onCreate. Do you have any better ones?

Re-checked with 2.0.105-alpha-2015-06-30 4.3 GT-I9300 Samsung I9300 Galaxy 3S - no more crashes.

Dbrant closed this task as Resolved.Jul 21 2015, 12:00 PM