[TIMOB-20332] Closing a Ti.UI.TabGroup that contains a ti.map view crashes the app on Android
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2017-12-15T16:45:31.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 7.0.1 |
Components | Android |
Labels | andoid, ti.map |
Reporter | Terry Morgan |
Assignee | Yordan Banev |
Created | 2016-01-28T12:51:29.000+0000 |
Updated | 2017-12-19T18:52:14.000+0000 |
Description
Attempting to close a Ti.UI.TabGroup when it contains a ti.map map view in one of it's tabs causes the app crash.
Test case:
// this sets the background color of the master UIView (when there are no windows/tab groups on it)
Titanium.UI.setBackgroundColor('#000');
// create tab group
var tabGroup = Titanium.UI.createTabGroup();
var win1 = Titanium.UI.createWindow({
title:'Tab 1',
backgroundColor:'#fff'
});
var tab1 = Titanium.UI.createTab({
icon:'KS_nav_views.png',
title:'Tab 1',
window:win1
});
var Map = require('ti.map');
var mapview = Map.createView();
win1.add(mapview);
tabGroup.addTab(tab1);
tabGroup.open();
// Close the tabGroup after 8 seconds
setTimeout(function(){
console.log("Closing tabGroup");
tabGroup.close();
}, 8000);
Stack trace:
{panel}
[ERROR] TiApplication: (main) [8315,8315] Sending event: exception on thread: main msg:java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object java.util.ArrayList.set(int, java.lang.Object)' on a null object reference; Titanium 5.1.2,2015/12/16 19:00,ca822b2
[ERROR] TiApplication: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object java.util.ArrayList.set(int, java.lang.Object)' on a null object reference
[ERROR] TiApplication: at android.support.v4.app.FragmentManagerImpl.makeInactive(FragmentManager.java:1261)
[ERROR] TiApplication: at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1168)
[ERROR] TiApplication: at android.support.v4.app.FragmentManagerImpl.removeFragment(FragmentManager.java:1304)
[ERROR] TiApplication: at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:708)
[ERROR] TiApplication: at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1572)
[ERROR] TiApplication: at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:493)
[ERROR] TiApplication: at android.os.Handler.handleCallback(Handler.java:739)
[ERROR] TiApplication: at android.os.Handler.dispatchMessage(Handler.java:95)
[ERROR] TiApplication: at android.os.Looper.loop(Looper.java:145)
[ERROR] TiApplication: at android.app.ActivityThread.main(ActivityThread.java:5832)
[ERROR] TiApplication: at java.lang.reflect.Method.invoke(Native Method)
[ERROR] TiApplication: at java.lang.reflect.Method.invoke(Method.java:372)
[ERROR] TiApplication: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
[ERROR] TiApplication: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
[ERROR] AndroidRuntime: FATAL EXCEPTION: main
[ERROR] AndroidRuntime: Process: com.thevirtualforge.tabtest2, PID: 6616
[ERROR] AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object java.util.ArrayList.set(int, java.lang.Object)' on a null object reference
[ERROR] AndroidRuntime: at android.support.v4.app.FragmentManagerImpl.makeInactive(FragmentManager.java:1261)
[ERROR] AndroidRuntime: at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1168)
[ERROR] AndroidRuntime: at android.support.v4.app.FragmentManagerImpl.removeFragment(FragmentManager.java:1304)
[ERROR] AndroidRuntime: at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:708)
[ERROR] AndroidRuntime: at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1572)
[ERROR] AndroidRuntime: at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:493)
[ERROR] AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:739)
[ERROR] AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:95)
[ERROR] AndroidRuntime: at android.os.Looper.loop(Looper.java:145)
[ERROR] AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5832)
[ERROR] AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
[ERROR] AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:372)
[ERROR] AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
[ERROR] AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
{panel}
Hello We tested this issue using provided test code but couldn't reproduce it. App runs as expected in our environment. *Testing Environment:* Appcelerator Studio, build: 4.4.0.201511241829 Appcelerator Command-Line Interface, version 5.1.0 Titanium Command-Line Interface, CLI version 5.0.5, Titanium SDK version : 5.1.0GA, 5.1.2 GA Device : Nexus 7(android version: 6) *Test code*: Provided by the reporter *Test output*:
Thanks
We can reproduce this consistently across two different developer's environments. Please can you confirm what version of ti.map you're using in your test?
Hello, I am using ti.map version 2.3.4. Thanks.
Thanks, can you also confirm the following please: 1/ You saw the map open correctly. This issue is specific to maps in tabGroups. The map must display to trigger the crash. 2/ You waited 8 seconds and saw the tabGroup close normally.
Hello Yes, map opens correctly. After 8 seconds tabGroup closes and on device it shows "Unfortunately, app has stopped" message. If we click on ok button of the message then it doesn't show any error on the console log. Thanks.
{quote}on device it shows "Unfortunately, app has stopped" message{quote} So, the app IS crashing? You're just not seeing the stack trace, correct?
Can you share your tiapp.xml? Make sure you have made all the necessary changes in the tiapp.xml file like adding the API key for the map because stack trace doesn't show any crash log on my side. Useful link: http://docs.appcelerator.com/platform/latest/#!/api/Modules.Map Or, you can share your full project in a github link so that we can look into this issue. Thanks.
The stack trace not appearing is irrelevant really. That's just a symptom the crash which you have reproduced, as indicated by the "Unfortunately, the app has stopped" message you are seeing. Here's my tiapp.xml, as requested. You'll need to add your own Google Maps api key in place of xxxxxxx:
I can confirm this bug. For me, it only happens if you close the tabgroup via "tabGroup.close();". It does not crash if you use the android backbutton to close the tabgroup. So a workaround for me is to write
instead of
For me this even happens if I remove the map view like this: {noformat} var mapWrapper = Ti.UI.createView(); var mapView = mapModule.createView({ animate: true }); mapWrapper.add(mapView); $.showMapView = function(){ self.add(mapWrapper); }; $.hideMapView = function(){ self.remove(mapWrapper); }; {noformat} The app crashes as soon as the remove method is executed. Has anybody tried this way?
This should be fixed since a while, can someone confirm with Ti.Map Android 3.3.x (e.g. 3.3.2)?
No news on this?
I did not receive any response lately, especially after using latest Ti.Map. If you still see this issue, we can schedule it.
PR: https://github.com/appcelerator/titanium_mobile/pull/9628
FR Passed for master. Waiting for merge to get enabled. [~ybanev], please provide a backport for this ticket.
7_0_X: https://github.com/appcelerator/titanium_mobile/pull/9678
FR Passed for backport, waiting for CR & merge to get enabled.
Master & backport PR merged.
Verified the fix with SDK 7.0.1.v20171218104141 & 7.1.0.v20171218101353. Closing. Studio Ver: 5.0.0.201712081732 SDK Ver: 7.0.1.v20171218104141, 7.1.0.v20171218101353 OS Ver: 10.12.3 Xcode Ver: Xcode 8.3.3 Appc NPM: 4.2.11 Appc CLI: 7.0.1-master.5 Daemon Ver: 1.0.1 Ti CLI Ver: 5.0.14 Alloy Ver: 1.10.10 Node Ver: 8.9.1 Java Ver: 1.8.0_101 Devices: ⇨ google Pixel --- Android 7.1.1 ⇨ google Nexus 5 --- Android 6.0.1