Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-20332] Closing a Ti.UI.TabGroup that contains a ti.map view crashes the app on Android

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2017-12-15T16:45:31.000+0000
Affected Version/sn/a
Fix Version/sRelease 7.0.1
ComponentsAndroid
Labelsandoid, ti.map
ReporterTerry Morgan
AssigneeYordan Banev
Created2016-01-28T12:51:29.000+0000
Updated2017-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}

Comments

  1. Jebun Naher 2016-01-31

    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*:
       [INFO] :   Project built successfully in 1m 31s 134ms
       -- Start application log -----------------------------------------------------
       [INFO] :   TiApplication: (main) [0,0] checkpoint, app created.
       [INFO] :   TiApplication: (main) [91,91] Titanium 5.1.2 (2015/12/16 19:00 ca822b2)
       [WARN] :   TiVerify: (Timer-0) [5004,5004] Verifying module licenses...
       [INFO] :   TiVerify: (Timer-0) [978,5982] Succesfully verified module licenses
       [INFO] :   APSAnalyticsService: Analytics Service Started
       
    Thanks
  2. Terry Morgan 2016-02-02

    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?
  3. Jebun Naher 2016-02-02

    Hello, I am using ti.map version 2.3.4. Thanks.
  4. Terry Morgan 2016-02-02

    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.
  5. Jebun Naher 2016-02-02

    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.
  6. Terry Morgan 2016-02-02

    {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?
  7. Jebun Naher 2016-02-02

    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.
  8. Terry Morgan 2016-02-02

    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:
       <?xml version="1.0" encoding="UTF-8"?>
       <ti:app xmlns:ti="http://ti.appcelerator.org">
       	<id>myappid.tabtest2</id>
       	<name>tabTest2</name>
       	<version>1.0</version>
       	<publisher>not specified</publisher>
       	<url></url>
       	<description></description>
       	<copyright>not specified</copyright>
       	<icon>appicon.png</icon>
       	<fullscreen>false</fullscreen>
       	<navbar-hidden>false</navbar-hidden>
       	<analytics>true</analytics>
       	<guid>741e5d6a-703a-40e6-9dc9-27cd2a1a1390</guid>
       	<property name="ti.ui.defaultunit" type="string">dp</property>
       	<ios>
       		<plist>
       			<dict>
       				<key>UISupportedInterfaceOrientations~iphone</key>
       				<array>
       					<string>UIInterfaceOrientationPortrait</string>
       				</array>
       				<key>UISupportedInterfaceOrientations~ipad</key>
       				<array>
       					<string>UIInterfaceOrientationPortrait</string>
       					<string>UIInterfaceOrientationPortraitUpsideDown</string>
       					<string>UIInterfaceOrientationLandscapeLeft</string>
       					<string>UIInterfaceOrientationLandscapeRight</string>
       				</array>
       				<key>UIRequiresPersistentWiFi</key>
       				<false/>
       				<key>UIPrerenderedIcon</key>
       				<false/>
       				<key>UIStatusBarHidden</key>
       				<false/>
       				<key>UIStatusBarStyle</key>
       				<string>UIStatusBarStyleDefault</string>
       			</dict>
       		</plist>
       	</ios>
       	<android xmlns:android="http://schemas.android.com/apk/res/android">
               <manifest>
                   <application>
                       <!-- Replace "PASTE YOUR GOOGLE MAPS API KEY HERE" with the Google API key you obtained -->
                       <meta-data android:name="com.google.android.maps.v2.API_KEY"
                           android:value="xxxxxxx"/>
                   </application>
               </manifest>
       	</android>
       	<mobileweb>
       		<precache>
       		</precache>
       		<splash>
       			<enabled>true</enabled>
       			<inline-css-images>true</inline-css-images>
       		</splash>
       		<theme>default</theme>
       	</mobileweb>
       	<modules>
               <module platform="android">ti.map</module>
       	</modules>
       	<deployment-targets>
       		<target device="android">true</target>
       		<target device="ipad">false</target>
       		<target device="iphone">false</target>
       		<target device="mobileweb">false</target>
       		<target device="windows">false</target>
       	</deployment-targets>
       	<sdk-version>5.1.2.GA</sdk-version>
       </ti:app>
       
  9. Low Bird 2016-04-04

    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
       tabGroup.activity.finish();
       
    instead of
       tabGroup.close()
       
  10. Muhammad Qasim 2017-03-07

    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?
  11. Hans Knöchel 2017-10-12

    This should be fixed since a while, can someone confirm with Ti.Map Android 3.3.x (e.g. 3.3.2)?
  12. Guillermo Figueras 2017-11-21

    No news on this?
  13. Hans Knöchel 2017-11-21

    I did not receive any response lately, especially after using latest Ti.Map. If you still see this issue, we can schedule it.
  14. Yordan Banev 2017-11-27

    PR: https://github.com/appcelerator/titanium_mobile/pull/9628
  15. Lokesh Choudhary 2017-12-11

    FR Passed for master. Waiting for merge to get enabled. [~ybanev], please provide a backport for this ticket.
  16. Yordan Banev 2017-12-12

    7_0_X: https://github.com/appcelerator/titanium_mobile/pull/9678
  17. Lokesh Choudhary 2017-12-12

    FR Passed for backport, waiting for CR & merge to get enabled.
  18. Lokesh Choudhary 2017-12-18

    Master & backport PR merged.
  19. Lokesh Choudhary 2017-12-19

    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

JSON Source