[TIMOB-26964] Android: Calling child window's close() method back to TabGroup fails if "Don't keep activities" is enabled
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | None |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2019-04-29T14:36:54.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 8.0.1 |
Components | Android |
Labels | TabGroup, android, close, engSchedule |
Reporter | Joshua Quick |
Assignee | Joshua Quick |
Created | 2019-04-04T18:51:21.000+0000 |
Updated | 2019-04-29T14:36:55.000+0000 |
Description
*Summary:*
If Android "Developer Options" setting "Don't keep activities" is enabled, then calling the Notice that the
close()
method on a child window which navigates back to a TabGroup
will do the following depending on the Titanium version:
* +8.0.0 and above+: Shows a blank window.
* +7.2.1 < 8.0.0+: Causes a crash.
* +7.2.0 and below+: Shows a blank window.
This is not an issue when tapping the Android "Back" button on the child window. It's only an issue when calling the child window's close()
method.
*Note:*
As of Titanium 7.2.1, back-navigating from a child window exits out of the app when "Don't keep activities" is enabled. Titanium no longer "restores" parent windows due to the memory leak fixes made in 7.2.1. This is a separate issue.
*Steps to reproduce:*
Go to the Android device's main "Settings" screen.
Tap on "System" under "Settings.
Tap on "Developer options" under "System" settings.
Enable "Don't keep activities", which should be near the bottom of the list.
Build and run the below code on the above Android device.
Tap on the "Open Child Window" button.
Tap on the "Close Window" button.
Notice that the TabGoup
will either be blank or the app will crash.
function createTab(title) {
var window = Ti.UI.createWindow({ title: title });
window.add(Ti.UI.createLabel({
text: title + " View",
top: "25%",
}));
var openButton = Ti.UI.createButton({
title: "Open Child Window",
top: "50%",
});
openButton.addEventListener("click", function() {
var childWindow = Ti.UI.createWindow({
title: title + " Child Window",
backgroundColor: "white",
});
var closeButton = Ti.UI.createButton({
title: "Close Window",
});
closeButton.addEventListener("click", function() {
childWindow.close();
});
childWindow.add(closeButton);
childWindow.open();
});
window.add(openButton);
var tab = Ti.UI.createTab({
title: title,
window: window,
});
return tab;
}
var tabGroup = Ti.UI.createTabGroup({
title: "TabGroup Parent Test",
tabs: [createTab("Tab 1"), createTab("Tab 2"), createTab("Tab 3")],
});
tabGroup.open();
*Result on Titanium 7.2.0 and Below:*
TabGroup
will be empty. No tabs are shown.
*Result on Titanium 8.0.0:*
TabGroup
will be empty. No tabs are shown.
*Result on Titanium 7.2.1 - 7.5.1:*
The app will crash for these Titanium versions.
[ERROR] : TiExceptionHandler: (main) [89797,89797] Attempt to invoke virtual method 'android.app.Activity ti.modules.titanium.ui.TabGroupProxy.getActivity()' on a null object reference
[ERROR] : TiExceptionHandler:
[ERROR] : TiExceptionHandler: ti.modules.titanium.ui.widget.tabgroup.TiUIAbstractTab.getContentView(TiUIAbstractTab.java:55)
[ERROR] : TiExceptionHandler: ti.modules.titanium.ui.widget.tabgroup.TiUIActionBarTab$TabFragment.onCreateView(TiUIActionBarTab.java:52)
[ERROR] : TiExceptionHandler: android.support.v4.app.Fragment.performCreateView(Fragment.java:2346)
[ERROR] : TiExceptionHandler: android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1428)
[ERROR] : TiExceptionHandler: android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1759)
[ERROR] : TiExceptionHandler: android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1827)
[ERROR] : TiExceptionHandler: android.support.v4.app.FragmentManagerImpl.dispatchStateChange(FragmentManager.java:3244)
[ERROR] : TiExceptionHandler: android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:3200)
[ERROR] : TiExceptionHandler: android.support.v4.app.FragmentController.dispatchActivityCreated(FragmentController.java:195)
[ERROR] : TiExceptionHandler: android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:597)
[ERROR] : TiExceptionHandler: android.support.v7.app.AppCompatActivity.onStart(AppCompatActivity.java:177)
[ERROR] : TiExceptionHandler: org.appcelerator.titanium.TiBaseActivity.onStart(TiBaseActivity.java:1504)
[ERROR] : TiExceptionHandler: android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1391)
[ERROR] : TiExceptionHandler: android.app.Activity.performStart(Activity.java:7157)
[ERROR] : TiExceptionHandler: android.app.ActivityThread.handleStartActivity(ActivityThread.java:2937)
[ERROR] : TiExceptionHandler: android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:180)
[ERROR] : TiExceptionHandler: android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:165)
[ERROR] : TiExceptionHandler: android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:142)
[ERROR] : TiExceptionHandler: android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70)
[ERROR] : TiExceptionHandler: android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
[ERROR] : TiExceptionHandler: android.os.Handler.dispatchMessage(Handler.java:106)
[ERROR] : TiExceptionHandler: android.os.Looper.loop(Looper.java:193)
[ERROR] : TiExceptionHandler: android.app.ActivityThread.main(ActivityThread.java:6669)
[ERROR] : TiExceptionHandler: java.lang.reflect.Method.invoke(Native Method)
[ERROR] : TiExceptionHandler: com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
[ERROR] : TiExceptionHandler: com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
PR (master): https://github.com/appcelerator/titanium_mobile/pull/10829
PR (8.0.x): https://github.com/appcelerator/titanium_mobile/pull/10868
FR passed PR merged.
Closing ticket, fix verified in SDK version 8.0.1.v20190426162041 and SDK version 8.1.0.v20190426222341. Test and other information can be found at: Master : https://github.com/appcelerator/titanium_mobile/pull/10829 8_0_X: https://github.com/appcelerator/titanium_mobile/pull/10868