[TIMOB-14393] Android: JS proxies are prematurely cleaned up when dalvik gc is triggered
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | High |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2015-06-01T22:58:56.000+0000 |
| Affected Version/s | Release 3.1.1 |
| Fix Version/s | Release 4.1.0 |
| Components | Android |
| Labels | supportTeam |
| Reporter | Allen Yeung |
| Assignee | Pedro Enrique |
| Created | 2013-06-26T18:46:16.000+0000 |
| Updated | 2017-03-31T22:22:36.000+0000 |
Description
Attachments
| File | Date | Size |
|---|---|---|
| S4_logs.txt | 2014-03-22T00:16:21.000+0000 | 49042 |
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).
This causes major headaches for my app, lots of crash reports and no easy fix without a major refactoring.
PR: https://github.com/appcelerator/titanium_mobile/pull/6887
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();Closing ticket as fixed, if there are any problems, please file a new ticket.