Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-20585] Android : Crashing when we are at two map view in scrollable view and click go back

GitHub Issuen/a
TypeBug
PriorityCritical
StatusResolved
ResolutionNeeds more info
Resolution Date2018-08-01T16:07:59.000+0000
Affected Version/sRelease 5.2.0
Fix Version/sn/a
ComponentsAndroid
LabelsmapView
ReporterAminul Islam
AssigneeAshraf Abu
Created2016-03-16T20:22:15.000+0000
Updated2018-08-01T16:08:12.000+0000

Description

In this new window I have one button called go back and pressing this button will close this window and taking you to the first map view to the scrollable view.But this is crashing here when we are at 2 map view in scrollable view and click go back. Please find the attached test project . Environment
android 5.0.2 
ti.map 2.3.6
Operating System
  Name                        = Mac OS X
  Version                     = 10.11.2
  Architecture                = 64bit
  # CPUs                      = 4
  Memory                      = 8589934592
Node.js
  Node.js Version             = 0.12.0
  npm Version                 = 3.8.1
Titanium CLI
  CLI Version                 = 5.0.6
Titanium SDK
  SDK Version                 = 5.2.0.GA
  SDK Path                    = /Users/Raju/Library/Application Support/Titanium/mobilesdk/osx/5.2.0.GA
  Target Platform             = android
Thanks

Attachments

FileDateSize
Android error log.rtf2016-04-13T07:08:08.000+00003690
SampleMap.zip2016-03-16T20:25:24.000+00008531177
sampleMapMultipleView.zip2016-04-13T07:07:41.000+00008414655
sampleMapMultipleView 2.zip2016-05-04T04:13:32.000+00008414773

Comments

  1. Ashraf Abu 2016-03-30

    Crash Logs:
       03-29 20:10:35.586  7813  7813 D AndroidRuntime: Shutting down VM
       03-29 20:10:35.589  7813  7813 E TiApplication: (main) [460476,460476] Sending event: exception on thread: main msg:java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState; Titanium 5.2.0,2016/02/20 08:05,384775e
       03-29 20:10:35.589  7813  7813 E TiApplication: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
       03-29 20:10:35.589  7813  7813 E TiApplication: 	at android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1448)
       03-29 20:10:35.589  7813  7813 E TiApplication: 	at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1466)
       03-29 20:10:35.589  7813  7813 E TiApplication: 	at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:634)
       03-29 20:10:35.589  7813  7813 E TiApplication: 	at android.support.v4.app.BackStackRecord.commit(BackStackRecord.java:613)
       03-29 20:10:35.589  7813  7813 E TiApplication: 	at org.appcelerator.titanium.view.TiUIFragment.release(TiUIFragment.java:88)
       03-29 20:10:35.589  7813  7813 E TiApplication: 	at ti.map.TiUIMapView.release(TiUIMapView.java:905)
       03-29 20:10:35.589  7813  7813 E TiApplication: 	at org.appcelerator.titanium.proxy.TiViewProxy.releaseViews(TiViewProxy.java:539)
       03-29 20:10:35.589  7813  7813 E TiApplication: 	at org.appcelerator.titanium.proxy.TiViewProxy.releaseViews(TiViewProxy.java:536)
       03-29 20:10:35.589  7813  7813 E TiApplication: 	at ti.modules.titanium.ui.widget.TiUIScrollableView$ViewPagerAdapter.destroyItem(TiUIScrollableView.java:503)
       03-29 20:10:35.589  7813  7813 E TiApplication: 	at android.support.v4.view.PagerAdapter.destroyItem(PagerAdapter.java:124)
       03-29 20:10:35.589  7813  7813 E TiApplication: 	at android.support.v4.view.ViewPager.populate(ViewPager.java:1074)
       03-29 20:10:35.589  7813  7813 E TiApplication: 	at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:552)
       03-29 20:10:35.589  7813  7813 E TiApplication: 	at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:514)
       03-29 20:10:35.589  7813  7813 E TiApplication: 	at android.support.v4.view.ViewPager.setCurrentItem(ViewPager.java:506)
       03-29 20:10:35.589  7813  7813 E TiApplication: 	at ti.modules.titanium.ui.widget.TiUIScrollableView.move(TiUIScrollableView.java:395)
       03-29 20:10:35.589  7813  7813 E TiApplication: 	at ti.modules.titanium.ui.widget.TiUIScrollableView.scrollTo(TiUIScrollableView.java:401)
       03-29 20:10:35.589  7813  7813 E TiApplication: 	at ti.modules.titanium.ui.ScrollableViewProxy.handleMessage(ScrollableViewProxy.java:99)
       03-29 20:10:35.589  7813  7813 E TiApplication: 	at android.os.Handler.dispatchMessage(Handler.java:98)
       03-29 20:10:35.589  7813  7813 E TiApplication: 	at android.os.Looper.loop(Looper.java:148)
       03-29 20:10:35.589  7813  7813 E TiApplication: 	at android.app.ActivityThread.main(ActivityThread.java:5417)
       03-29 20:10:35.589  7813  7813 E TiApplication: 	at java.lang.reflect.Method.invoke(Native Method)
       03-29 20:10:35.589  7813  7813 E TiApplication: 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
       03-29 20:10:35.589  7813  7813 E TiApplication: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
       03-29 20:10:35.596   381  1229 D audio_hw_primary: out_set_parameters: enter: usecase(1: low-latency-playback) kvpairs: routing=2
       03-29 20:10:35.625  7813  7813 E AndroidRuntime: FATAL EXCEPTION: main
       03-29 20:10:35.625  7813  7813 E AndroidRuntime: Process: com.appcelerator.test.sg, PID: 7813
       03-29 20:10:35.625  7813  7813 E AndroidRuntime: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
       03-29 20:10:35.625  7813  7813 E AndroidRuntime: 	at android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1448)
       03-29 20:10:35.625  7813  7813 E AndroidRuntime: 	at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1466)
       03-29 20:10:35.625  7813  7813 E AndroidRuntime: 	at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:634)
       03-29 20:10:35.625  7813  7813 E AndroidRuntime: 	at android.support.v4.app.BackStackRecord.commit(BackStackRecord.java:613)
       03-29 20:10:35.625  7813  7813 E AndroidRuntime: 	at org.appcelerator.titanium.view.TiUIFragment.release(TiUIFragment.java:88)
       03-29 20:10:35.625  7813  7813 E AndroidRuntime: 	at ti.map.TiUIMapView.release(TiUIMapView.java:905)
       03-29 20:10:35.625  7813  7813 E AndroidRuntime: 	at org.appcelerator.titanium.proxy.TiViewProxy.releaseViews(TiViewProxy.java:539)
       03-29 20:10:35.625  7813  7813 E AndroidRuntime: 	at org.appcelerator.titanium.proxy.TiViewProxy.releaseViews(TiViewProxy.java:536)
       03-29 20:10:35.625  7813  7813 E AndroidRuntime: 	at ti.modules.titanium.ui.widget.TiUIScrollableView$ViewPagerAdapter.destroyItem(TiUIScrollableView.java:503)
       03-29 20:10:35.625  7813  7813 E AndroidRuntime: 	at android.support.v4.view.PagerAdapter.destroyItem(PagerAdapter.java:124)
       03-29 20:10:35.625  7813  7813 E AndroidRuntime: 	at android.support.v4.view.ViewPager.populate(ViewPager.java:1074)
       03-29 20:10:35.625  7813  7813 E AndroidRuntime: 	at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:552)
       03-29 20:10:35.625  7813  7813 E AndroidRuntime: 	at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:514)
       03-29 20:10:35.625  7813  7813 E AndroidRuntime: 	at android.support.v4.view.ViewPager.setCurrentItem(ViewPager.java:506)
       03-29 20:10:35.625  7813  7813 E AndroidRuntime: 	at ti.modules.titanium.ui.widget.TiUIScrollableView.move(TiUIScrollableView.java:395)
       03-29 20:10:35.625  7813  7813 E AndroidRuntime: 	at ti.modules.titanium.ui.widget.TiUIScrollableView.scrollTo(TiUIScrollableView.java:401)
       03-29 20:10:35.625  7813  7813 E AndroidRuntime: 	at ti.modules.titanium.ui.ScrollableViewProxy.handleMessage(ScrollableViewProxy.java:99)
       03-29 20:10:35.625  7813  7813 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:98)
       03-29 20:10:35.625  7813  7813 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:148)
       03-29 20:10:35.625  7813  7813 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:5417)
       03-29 20:10:35.625  7813  7813 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
       03-29 20:10:35.625  7813  7813 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
       03-29 20:10:35.625  7813  7813 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
       03-29 20:10:35.627   865  1618 W ActivityManager:   Force finishing activity com.appcelerator.test.sg/org.appcelerator.titanium.TiActivity
       03-29 20:10:35.640   381  1229 D AudioFlinger: mixer(0xb3e40000) throttle end: throttle time(4)
       
  2. Ashraf Abu 2016-03-30

    [~aislam] Issue seems to be this part of the code:-
       function openWindow(e) {
           Alloy.createController("popup",{
               gotoPageCallBack : moveToPage
           }).getView().open();
       }
       
    When you call the "moveToPage" on callback, the error as above occurs.
       function moveToPage(id){
           $.svMainView.scrollToView(id);
       }
       
    This occurs cause that method is being called when the other window is still present. Is that method necessary?
  3. Ashraf Abu 2016-04-12

    It seems that the purpose is to scroll to view 0 once you go back to the scrollable view. Here's a work around that works:- popup.js
       var args = arguments[0] || {};
       
       function goBack(){
       	
       	$.popup.close();
       	//args.gotoPageCallBack(0);
       }
       
    index.js
       Map = require("ti.map");
       var moment = require('alloy/moment');
       function openWindow(e) {
       	Alloy.createController("popup",{
       		gotoPageCallBack : moveToPage
       	}).getView().open();
       }
       
       for (var i = 0; i < 4; i++) {
       	var mountainView = Map.createAnnotation({
       		latitude : 22.572646,
       		longitude : 88.363895,
       		title : "Appcelerator Headquarters",
       		subtitle : 'Mountain View, CA',
       		pincolor : Map.ANNOTATION_RED,
       		myid : 1 // Custom property to uniquely identify this annotation.
       	});
       	var mapview = Map.createView({
       		mapType : Map.NORMAL_TYPE,
       		region : {
       			latitude : 22.572646,
       			longitude : 88.363895,
       			latitudeDelta : 0.9,
       			longitudeDelta : 0.9
       		},
       		top : "50",
       		animate : true,
       		regionFit : true,
       		annotations : [mountainView]
       	});
       	var mapContainer = Titanium.UI.createView({
       		width : "80%",
       		height : Titanium.UI.FILL,
       		touchEnabled : false,
       		backgroundColor : "#000000"
       	});
       	
       	
       	
       	//mapview.addEventListener("complete",completed);
       	mapContainer.add(mapview);
       	$.svMainView.addView(mapContainer);
       	
       }
       $.lPageNo.text = "Current page is " + $.svMainView.getCurrentPage();
       $.index.open();
       $.index.addEventListener('focus', function(e) {
           moveToPage(0);
       });
       
       // function completed(){
       // mapview.annotations = [mountainView];
       // }
       
       //alert(pickupDate);
       function onScrollend(){
       	$.lPageNo.text = "Current page is " + $.svMainView.getCurrentPage(); 
       }
       function moveToPage(id){
       	$.svMainView.scrollToView(id);
       }
       
    The issue is scrollToView is being called while the popup window is closing in android and the scrollableview is coming back in view. Basically the sequence of things. The workaround code that I've written puts a listener on the mainview to scroll to view 0 once it comes back to focus. [~aislam] and [~rmitro] is this workaround okay? Calling scrollToView from a callback in another window is not really advisable.
  4. Rakhi Mitro 2016-04-13

    [~msamah] For the second issue- if each view of the scrollable view has more views along with map view, then during the swiping to the left or right of the scrollable view also causes app crashes with the same error log. Please see the attached source code and error log. It is not happening all the time, but if you scroll left, right very quickly then it is happening. The Customer is using Samsung galaxy s6.
  5. Ashraf Abu 2016-04-14

    Thank you for the information. Will look into this.
  6. Ashraf Abu 2016-04-14

    [~rmitro] Was able to reproduce the crash. Here's a fix for that In the loadDetails.xml change line 31 to this:- <ScrollableView id = "svCurrentLoad" cacheSize="5" currentPage="0" onScroll="onScrollCurrentPosition"/> Basically to set ScrollableView to use a cache for the views with size 5. If they are going to use more views, the cacheSize should be equal or more to that. This should stop it from crashing. Let me know if it solves the issue. If everything is okay, I'll resolve this ticket.
  7. Ashraf Abu 2016-04-20

    I'll resolve this as it seems there's no more updates or issues.
  8. Ashraf Abu 2016-05-03

    [~rmitro] Does running this on 5.2.2.GA cause any crash for you? It doesn't seem to be crashing on 5.2.2.GA. (I'm not using any cacheSize)

JSON Source