Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-14393] Android: JS proxies are prematurely cleaned up when dalvik gc is triggered

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2015-06-01T22:58:56.000+0000
Affected Version/sRelease 3.1.1
Fix Version/sRelease 4.1.0
ComponentsAndroid
LabelssupportTeam
ReporterAllen Yeung
AssigneePedro Enrique
Created2013-06-26T18:46:16.000+0000
Updated2017-03-31T22:22:36.000+0000

Description

Attachments

FileDateSize
S4_logs.txt2014-03-22T00:16:21.000+000049042

Comments

  1. Yuri Goldfeld 2014-03-20

    This just hit us (SDK 3.2.0) and is rather horrendous and insidious, because it is not consistently reproducible and is difficult to diagnose (for us it manifests itself as a crash, but it's a native crash and thus is not caught by ACRA for example). It also makes one extremely paranoid, because if one cannot count on the JavaScript scope pattern, then basically the app is a ticking time bomb. In our case the problem happened to be a View created in a closure in a CommonJS module, with the View (being a simple red border used for error display) added or removed to/from another view when an error is detected or not. (Yes, now that we know the cause, we can work around it by using another technique, but like I said, what other semi-reproducible similar problems lurk?) We only caught this after upgrading to SDK 3.2.0; not reported when we used 3.1.1; it might be due to something changing about GC itself (speculation).
  2. Frank Apap 2014-04-29

    This causes major headaches for my app, lots of crash reports and no easy fix without a major refactoring.
  3. Pedro Enrique 2015-05-29

    PR: https://github.com/appcelerator/titanium_mobile/pull/6887
  4. Pedro Enrique 2015-06-01

    To test, use this code, run on emulator for consistent results
       function createView() {
       
       	var view = Ti.UI.createView({
       		backgroundColor: 'white'
       	});
       	var gc = Ti.UI.createButton({
       		top: '10dp',
       		title: "First, click here many time quickly (cause GC)",
       		color: 'black'
       	});
       	var btn = Ti.UI.createButton({
       		title: "Next, click here",
       		color: 'black'
       	});
       	view.add(btn);
       	view.add(gc);
       
       	// Label not attached to the view yet, but will be in the btn event listener
       	var label = Ti.UI.createLabel({
       		text: 'Hello World', bottom: '10dp',
       		color: 'black'
       	});
       
       	gc.addEventListener('click', function(){
       		Ti.API.info('Forcing GC...');
       		for (var i = 0; i < 2000; i++) {
       			Ti.UI.createButton();
       		}
       		Ti.API.info('Done with GC...');
       	});
       	btn.addEventListener('click', function(){
       		view.add(label);
       	});
       
       	return view;
       }
        
        
       var win = Ti.UI.createWindow();
       var view = createView();
       win.add(view);
       win.open();
       
  5. Lee Morris 2017-03-31

    Closing ticket as fixed, if there are any problems, please file a new ticket.

JSON Source