[TIMOB-24839] Android: Reopening a closed window crashes the app
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2017-06-19T20:38:46.000+0000 |
Affected Version/s | Release 6.1.0, Release 6.1.1 |
Fix Version/s | Release 6.1.1 |
Components | Android |
Labels | android, api, parity, regression |
Reporter | Muhammad Ahmed Fahad |
Assignee | Gary Mathews |
Created | 2017-06-16T03:50:20.000+0000 |
Updated | 2017-06-21T16:41:29.000+0000 |
Description
Environment: 6.1.1.v20170615113917 Android 7.1.2 Device: OnePlus One (A0001)
Affected version 6.1.0
var egWindow = Ti.UI.createWindow({
width: Ti.UI.FILL,
height: Ti.UI.FILL,
backgroundColor: 'red'
});
$.addListener($.button, 'click', function(){
egWindow.open();
});
once the window is open, click the back button to close the window, and click the window again to open the window and the app crashes. This didn't use to be the case in 6.0.4.
Crash Log: https://s3-ap-southeast-1.amazonaws.com/uploads-ap.hipchat.com/56929/750866/TQ8ifcaui4kpuoU/Crash_Log.txt
Please can anyone look at this ASAP? Without this fixed, our app would be pretty much unusable. Also we need this version of the SDK as we need support for modules with .aar libs.
[~fahad86] Thanks for this report! I'm moving this across to TIMOB Can reproduce this using: SDK: 6.1.0.GA, 6.1.1.v20170615113917 Appc CLI: 6.2.2 Appc NPM: 4.2.9 OnePlus 3 7.1.1
Crash log https://gist.github.com/ewanharris/f5e4105115ea85f4a5a0c4a4e93a7b0d (too big for jira)
Thanks Ewan! Curious. Can I expect the fix in 6.1.1.GA (i.e. Fix Version/s: 6.1.1)?
master: https://github.com/appcelerator/titanium_mobile/pull/9145 6_1_X: https://github.com/appcelerator/titanium_mobile/pull/9146
FR Passed for both master & backport PR.
Verified the fix with SDK's 6.2.0.v20170619134258 & 6.1.1.v20170619143158. Reopening a closed window does not crash the app. Closing. Studio Ver: 4.9.0.201705302345 OS Ver: 10.12.3 Xcode Ver: Xcode 8.3.3 Appc NPM: 4.2.9 Appc CLI: 6.2.2 Ti CLI Ver: 5.0.14 Alloy Ver: 1.9.11 Node Ver: 6.10.1 Java Ver: 1.8.0_101 Devices: ⇨ google Pixel --- Android 7.1.1 ⇨ google Nexus 5 --- Android 6.0.1
Trying 6.1.1.v20170619143158, and I still see some issues. Looks like the view proxy is getting reset and when I try to re-open the window, all I see is a blank (white) screen. When I invoke a function which modifies a list view inside the closed window, I get the error: "Uncaught Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference" I'm using nl.fokkezb.infiniteScroll widget to load data on the List view inside the window.
So in essence the window could be re-opened without crash but everything added or attached to the window is already gone, which defeats the purpose.
I did a diff of the TiBaseActivity.java of 6_0_X and found that the bug may be occurring due to the logic change in the method
onBackPressed
Kindly verify the code change here // check Ti.UI.Window.exitOnClose and either // exit the application or send to background if (topWindow != null) { boolean exitOnClose = TiConvert.toBoolean(topWindow.getProperty(TiC.PROPERTY_EXIT_ON_CLOSE), false); // root window should exitOnClose by default if (totalWindowStack <= 1 && !topWindow.hasProperty(TiC.PROPERTY_EXIT_ON_CLOSE)) { exitOnClose = true; } if (exitOnClose) { Log.d(TAG, "onBackPressed: exit"); if (Build.VERSION.SDK_INT >= 16) { finishAffinity(); } else { TiApplication.terminateActivityStack(); } return; // root window has exitOnClose set as false, send to background } else if (totalWindowStack <= 1) { Log.d(TAG, "onBackPressed: suspend to background"); this.moveTaskToBack(true); return; } removeWindowFromStack(topWindow); }// root window should exitOnClose by default if (totalWindowStack <= 1 && {color:red}*!*{color}topWindow.hasProperty(TiC.PROPERTY_EXIT_ON_CLOSE)) { exitOnClose = true; } typo in highlighted in red?
Please re-open
I would suggest to revert or re-evaluate the changes on the files TiBaseActivity.java and KrollProxy.java in comparison to the 6_0_X branch
Anyone looking at these messages?? (-)
[~fahad86] We are looking into it, thanks for bringing this to attention.