[TIMOB-27884] Android: Closing an Android window before it is loaded caused multiple exceptions
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Open |
Resolution | Unresolved |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Android |
Labels | n/a |
Reporter | Hans Knöchel |
Assignee | Unknown |
Created | 2020-05-07T09:48:19.000+0000 |
Updated | 2020-05-07T11:15:15.000+0000 |
Description
We are testing our app with slow internet and noticed that windows can glitch into a bad state when we close a window before things like requests are finished. Two significant issues were noticed so far:
1. The
window.activity.invalidateOptionsMenu()
function throws:
[ERROR] TiExceptionHandler: $.window.activity.invalidateOptionsMenu();
[ERROR] TiExceptionHandler: ^
[ERROR] TiExceptionHandler: TypeError: $.window.activity.invalidateOptionsMenu is not a function
The weird thing is, that $.window.activity
is non-null and even $.window.activity.invalidateOptionsMenu
exists, but invalidateOptionsMenu
is not a function (typeof $.window.activity.invalidateOptionsMenu === 'function'
returns false
).
2. After guarding that method (which is of course only called if the window is opened already to ensure the activity is set), we get a new error:
[ERROR] TiExceptionHandler: (main) [12419,36218] No view found for id 0x6 (unknown) for fragment SupportMapFragment{28f7639 (8611988b-d704-48f9-b6a6-4353808e1828) id=0x6}
[ERROR] TiExceptionHandler:
[ERROR] TiExceptionHandler: androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:875)
[ERROR] TiExceptionHandler: androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1238)
[ERROR] TiExceptionHandler: androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1303)
[ERROR] TiExceptionHandler: androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:439)
[ERROR] TiExceptionHandler: androidx.fragment.app.FragmentManagerImpl.executeOps(FragmentManagerImpl.java:2079)
[ERROR] TiExceptionHandler: androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:1869)
[ERROR] TiExceptionHandler: androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerImpl.java:1824)
[ERROR] TiExceptionHandler: androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManagerImpl.java:1727)
[ERROR] TiExceptionHandler: androidx.fragment.app.FragmentManagerImpl$2.run(FragmentManagerImpl.java:150)
[ERROR] TiExceptionHandler: android.os.Handler.handleCallback(Handler.java:907)
[ERROR] TiExceptionHandler: android.os.Handler.dispatchMessage(Handler.java:99)
[ERROR] TiExceptionHandler: android.os.Looper.loop(Looper.java:223)
[ERROR] TiExceptionHandler: android.app.ActivityThread.main(ActivityThread.java:7476)
[ERROR] TiExceptionHandler: java.lang.reflect.Method.invoke(Native Method)
[ERROR] TiExceptionHandler: com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:549)
[ERROR] TiExceptionHandler: com.android.internal.os.ZygoteInit.main(ZygoteInit.java:939)
together with a more complex log about the activity state:
[ERROR] E/com.myapp.app: Invalid ID 0x00000006.
[ERROR] FragmentManager: No view found for id 0x6 (unknown) for fragment SupportMapFragment{28f7639 (8611988b-d704-48f9-b6a6-4353808e1828) id=0x6}
[ERROR] FragmentManager: Activity state:
[DEBUG] FragmentManager: Local Activity 849141c State:
[DEBUG] FragmentManager: mResumed=false mStopped=true mFinished=false
[DEBUG] FragmentManager: mLastDispatchedIsInMultiWindowMode=null mLastDispatchedIsInPictureInPictureMode=null
[DEBUG] FragmentManager: mChangingConfigurations=false
[DEBUG] FragmentManager: mCurrentConfig={1.0 310mcc260mnc [en_US] ldltr sw411dp w411dp h659dp 420dpi nrml port night finger qwerty/v/v -nav/h winConfig={ mBounds=Rect(0, 0 - 1080, 1920) mAppBounds=Rect(0, 0 - 1080, 1794) mWindowingMode=fullscreen mDisplayWindowingMode=fullscreen mActivityType=standard mAlwaysOnTop=undefined mRotation=ROTATION_0} s.1}
[DEBUG] FragmentManager: mLoadersStarted=true
[DEBUG] FragmentManager: Active Fragments in 630e47e:
[DEBUG] FragmentManager: #0: ReportFragment{fe3dddf #0 androidx.lifecycle.LifecycleDispatcher.report_fragment_tag}
[DEBUG] FragmentManager: mFragmentId=#0 mContainerId=#0 mTag=androidx.lifecycle.LifecycleDispatcher.report_fragment_tag
[DEBUG] FragmentManager: mState=3 mIndex=0 mWho=android:fragment:0 mBackStackNesting=0
[DEBUG] FragmentManager: mAdded=true mRemoving=false mFromLayout=false mInLayout=false
[DEBUG] FragmentManager: mHidden=false mDetached=false mMenuVisible=true mHasMenu=false
[DEBUG] FragmentManager: mRetainInstance=false mRetaining=false mUserVisibleHint=true
[DEBUG] FragmentManager: mFragmentManager=FragmentManager{630e47e in HostCallbacks{b199a2c}}
[DEBUG] FragmentManager: mHost=android.app.Activity$HostCallbacks@b199a2c
[DEBUG] FragmentManager: Child FragmentManager{e83cf5 in ReportFragment{fe3dddf}}:
[DEBUG] FragmentManager: FragmentManager misc state:
[DEBUG] FragmentManager: mHost=android.app.Activity$HostCallbacks@b199a2c
[DEBUG] FragmentManager: mContainer=android.app.Fragment$1@ff2ca8a
[DEBUG] FragmentManager: mParent=ReportFragment{fe3dddf #0 androidx.lifecycle.LifecycleDispatcher.report_fragment_tag}
[DEBUG] FragmentManager: mCurState=3 mStateSaved=true mDestroyed=false
[DEBUG] FragmentManager: Added Fragments:
[DEBUG] FragmentManager: #0: ReportFragment{fe3dddf #0 androidx.lifecycle.LifecycleDispatcher.report_fragment_tag}
[DEBUG] FragmentManager: FragmentManager misc state:
[DEBUG] FragmentManager: mHost=android.app.Activity$HostCallbacks@b199a2c
[DEBUG] FragmentManager: mContainer=android.app.Activity$HostCallbacks@b199a2c
[DEBUG] FragmentManager: mCurState=3 mStateSaved=true mDestroyed=false
[DEBUG] FragmentManager: ViewRoot:
[DEBUG] FragmentManager: mAdded=true mRemoved=false
[DEBUG] FragmentManager: mConsumeBatchedInputScheduled=false
[DEBUG] FragmentManager: mConsumeBatchedInputImmediatelyScheduled=false
[DEBUG] FragmentManager: mPendingInputEventCount=0
[DEBUG] FragmentManager: mProcessInputEventsScheduled=false
[DEBUG] FragmentManager: mTraversalScheduled=false mIsAmbientMode=false mUnbufferedInputSource=0
[DEBUG] FragmentManager: android.view.ViewRootImpl$NativePreImeInputStage: mQueueLength=0
[DEBUG] FragmentManager: android.view.ViewRootImpl$ImeInputStage: mQueueLength=0
[DEBUG] FragmentManager: android.view.ViewRootImpl$NativePostImeInputStage: mQueueLength=0
[DEBUG] FragmentManager: Choreographer:
[DEBUG] FragmentManager: mFrameScheduled=true
[DEBUG] FragmentManager: mLastFrameTime=5730542 (24 ms ago)
[DEBUG] FragmentManager:
[DEBUG] FragmentManager: InsetsController:
[DEBUG] FragmentManager: InsetsState
[DEBUG] FragmentManager: InsetsSource type=ITYPE_IME frame=[0,1053][1080,1920] visibleFrmae=[0,1053][1080,1920] visible=false
[DEBUG] FragmentManager: InsetsSource type=ITYPE_BOTTOM_TAPPABLE_ELEMENT frame=[0,1794][1080,1920] visible=true
[DEBUG] FragmentManager: InsetsSource type=ITYPE_TOP_TAPPABLE_ELEMENT frame=[0,0][1080,63] visible=true
[DEBUG] FragmentManager: InsetsSource type=ITYPE_RIGHT_GESTURES frame=[1080,0][1080,1920] visible=true
[DEBUG] FragmentManager: InsetsSource type=ITYPE_LEFT_GESTURES frame=[0,0][0,1920] visible=true
[DEBUG] FragmentManager: InsetsSource type=ITYPE_BOTTOM_GESTURES frame=[0,1794][1080,1920] visible=true
[DEBUG] FragmentManager: InsetsSource type=ITYPE_TOP_GESTURES frame=[0,0][1080,63] visible=true
[DEBUG] FragmentManager: InsetsSource type=ITYPE_CAPTION_BAR frame=[0,0][0,0] visible=true
[DEBUG] FragmentManager: InsetsSource type=ITYPE_NAVIGATION_BAR frame=[0,1794][1080,1920] visible=true
[DEBUG] FragmentManager: InsetsSource type=ITYPE_STATUS_BAR frame=[0,0][1080,63] visible=true
[DEBUG] FragmentManager: View Hierarchy:
[DEBUG] FragmentManager: DecorView@4d278fb[MyAppActivity]
[DEBUG] FragmentManager: android.widget.LinearLayout{b9c2d18 V.E...... ........ 0,0-1080,1794}
[DEBUG] FragmentManager: android.view.ViewStub{fccb371 G.E...... ......I. 0,0-0,0 #10201aa android:id/action_mode_bar_stub}
[DEBUG] FragmentManager: android.widget.RelativeLayout{33b0556 G.E...... ......I. 0,0-0,0 #10204cf android:id/title_container}
[DEBUG] FragmentManager: android.widget.ProgressBar{245a9d7 G.ED..... ......I. 0,0-0,0 #10203f4 android:id/progress_circular}
[DEBUG] FragmentManager: android.widget.ProgressBar{4b302c4 G.ED..... ......I. 0,0-0,0 #10203f5 android:id/progress_horizontal}
[DEBUG] FragmentManager: androidx.appcompat.widget.AppCompatTextView{2a815ad V.ED..... ......ID 0,0-0,0 #1020016 android:id/title}
[DEBUG] FragmentManager: android.widget.FrameLayout{8fa20e2 V.E...... ........ 0,63-1080,1794}
[DEBUG] FragmentManager: androidx.appcompat.widget.FitWindowsLinearLayout{9510c73 V.E...... ........ 0,0-1080,1731 #7f09002c app:id/action_bar_root}
[DEBUG] FragmentManager: androidx.appcompat.widget.ViewStubCompat{d3f8730 G.E...... ......I. 0,0-0,0 #7f090037 app:id/action_mode_bar_stub}
[DEBUG] FragmentManager: androidx.appcompat.widget.ContentFrameLayout{e5d5fa9 V.E...... ........ 0,0-1080,1731 #1020002 android:id/content}
[DEBUG] FragmentManager: org.appcelerator.titanium.view.TiCompositeLayout{69d692e VFE...... .F...... 0,0-1080,1731 aid=1073741824}
[DEBUG] FragmentManager: android.view.View{ea5fccf V.ED..... ......ID 0,1794-1080,1920 #1020030 android:id/navigationBarBackground}
[DEBUG] FragmentManager: android.view.View{6cde65c V.ED..... ......ID 0,0-1080,63 #102002f android:id/statusBarBackground}
[DEBUG] FragmentManager: Looper (main, tid 2) {9034d65}
[DEBUG] FragmentManager: Message 0: { when=-58ms what=1319 obj=0 target=android.os.Handler }
[DEBUG] FragmentManager: Message 1: { when=-19ms what=210 obj=[Ljava.lang.Object;@91aea3a target=android.os.Handler }
[DEBUG] FragmentManager: Message 2: { when=-17ms what=210 obj=[Ljava.lang.Object;@6af96eb target=android.os.Handler }
[DEBUG] FragmentManager: (Total messages: 3, polling=false, quitting=false)
[DEBUG] FragmentManager: AutofillManager:
[DEBUG] FragmentManager: sessionId: 2147483647
[DEBUG] FragmentManager: state: UNKNOWN
[DEBUG] FragmentManager: context: android.app.ContextImpl@d810c48
[DEBUG] FragmentManager: client: com.myapp.app.MyAppActivity@849141c (android.os.BinderProxy@dbb7a9f)
[DEBUG] FragmentManager: enabled: false
[DEBUG] FragmentManager: enabledAugmentedOnly: false
[DEBUG] FragmentManager: hasService: true
[DEBUG] FragmentManager: hasCallback: false
[DEBUG] FragmentManager: onInvisibleCalled false
[DEBUG] FragmentManager: last autofilled data: null
[DEBUG] FragmentManager: id of last fill UI shown: null
[DEBUG] FragmentManager: tracked views: null
[DEBUG] FragmentManager: fillable ids: null
[DEBUG] FragmentManager: entered ids: null
[DEBUG] FragmentManager: save trigger id: null
[DEBUG] FragmentManager: save on finish(): false
[DEBUG] FragmentManager: options: logLvl=0, compatMode=false, augmented=false, appDisabledExpiration=0
[DEBUG] FragmentManager: compat mode enabled: false
[DEBUG] FragmentManager: debug: false verbose: false
[DEBUG] FragmentManager: Autofill Compat Mode: false
[DEBUG] FragmentManager: No ContentCaptureManager
[DEBUG] FragmentManager: ResourcesManager:
[DEBUG] FragmentManager: cached apks: 0 [cache disabled]
[DEBUG] FragmentManager: total apks: 4
[DEBUG] FragmentManager: resources: 20
[DEBUG] FragmentManager: resource impls: 6
[DEBUG] FragmentManager: Local FragmentActivity 849141c State:
[DEBUG] FragmentManager: mCreated=true mResumed=false mStopped=true Active Fragments in 9605ae1:
[DEBUG] FragmentManager: SupportMapFragment{28f7639 (8611988b-d704-48f9-b6a6-4353808e1828) id=0x6}
[DEBUG] FragmentManager: mFragmentId=#6 mContainerId=#6 mTag=null
[DEBUG] FragmentManager: mState=1 mWho=8611988b-d704-48f9-b6a6-4353808e1828 mBackStackNesting=0
[DEBUG] FragmentManager: mAdded=true mRemoving=false mFromLayout=false mInLayout=false
[DEBUG] FragmentManager: mHidden=false mDetached=false mMenuVisible=true mHasMenu=false
[DEBUG] FragmentManager: mRetainInstance=false mUserVisibleHint=true
[DEBUG] FragmentManager: mFragmentManager=FragmentManager{9605ae1 in HostCallbacks{4bd7006}}
[DEBUG] FragmentManager: mHost=androidx.fragment.app.FragmentActivity$HostCallbacks@4bd7006
[DEBUG] FragmentManager: mArguments=Bundle[{MapOptions=GoogleMapOptions{MapType=-1, LiteMode=null, Camera=null, CompassEnabled=null, ZoomControlsEnabled=null, ScrollGesturesEnabled=null, ZoomGesturesEnabled=null, TiltGesturesEnabled=null, RotateGesturesEnabled=null, ScrollGesturesEnabledDuringRotateOrZoom=null, MapToolbarEnabled=null, AmbientEnabled=null, MinZoomPreference=null, MaxZoomPreference=null, LatLngBoundsForCameraTarget=null, ZOrderOnTop=false, UseViewLifecycleInFragment=null}}]
[DEBUG] FragmentManager: Child FragmentManager{76eb6c7 in SupportMapFragment{28f7639}}:
[DEBUG] FragmentManager: FragmentManager misc state:
[DEBUG] FragmentManager: mHost=androidx.fragment.app.FragmentActivity$HostCallbacks@4bd7006
[DEBUG] FragmentManager: mContainer=androidx.fragment.app.Fragment$4@abea4f4
[DEBUG] FragmentManager: mParent=SupportMapFragment{28f7639 (8611988b-d704-48f9-b6a6-4353808e1828) id=0x6}
[DEBUG] FragmentManager: mCurState=1 mStateSaved=false mStopped=false mDestroyed=false
[DEBUG] FragmentManager: Added Fragments:
[DEBUG] FragmentManager: #0: SupportMapFragment{28f7639 (8611988b-d704-48f9-b6a6-4353808e1828) id=0x6}
[DEBUG] FragmentManager: FragmentManager misc state:
[DEBUG] FragmentManager: mHost=androidx.fragment.app.FragmentActivity$HostCallbacks@4bd7006
[DEBUG] FragmentManager: mContainer=androidx.fragment.app.FragmentActivity$HostCallbacks@4bd7006
[DEBUG] FragmentManager: mCurState=2 mStateSaved=true mStopped=true mDestroyed=false
[DEBUG] AndroidRuntime: Shutting down VM
It can be reproduced in our app that provided to the team. For more details, please reach out!
The reason why this is happening is simple: When we close the window before the HTTP request is finished, there is no activity anymore because the window is closed already. But that should just be guarded properly in the SDK and skip any further steps then.