[TIMOB-26682] Android: ES6 template strings causing memory leak + crash
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Duplicate |
Resolution Date | 2020-12-04T20:31:20.000+0000 |
Affected Version/s | Release 7.5.0 |
Fix Version/s | n/a |
Components | Android |
Labels | n/a |
Reporter | Hans Knöchel |
Assignee | Abir Mukherjee |
Created | 2018-12-30T15:05:53.000+0000 |
Updated | 2020-12-04T20:31:20.000+0000 |
Description
When using the following example on Android (with ES6+ enabled), the app crashes:
const stringVar = 'myString';
const numberVar = 1.337;
const myValue = ${stringVar}${numberVar.toFixed(2).toLocaleString()} €
;
Error:
[ERROR] TiExceptionHandler: (main) [428,32694] ti:/titanium.js:146
[ERROR] TiExceptionHandler: value: function(property, value) {
[ERROR] TiExceptionHandler: ^
[ERROR] TiExceptionHandler: RangeError: Maximum call stack size exceeded
[ERROR] TiExceptionHandler: at Label.value (ti:/titanium.js:146:17)
[ERROR] TiExceptionHandler: at onSummaryChanged (/alloy/controllers/trip/detail/expenses/index.js:113:34)
The whole thing works fine on iOS. Please provide a workaround, thx!
[~hknoechel], does this definitely not happen when not using transpilation? There's nothing there that will be transpiled against that V8 version as far as I can see, I built an app with that code and am not seeing any signs. I also left an app running for 5 minutes and it didn't seem to crash for me. Is it an instant thing or a slow thing for you? If you're sure the issue is down to template literals you could try using string concatenation
const myValue = stringVar + numberVar.toFixed(2).toLocaleString() + ' €';
I took another look at this ticket. It doesn't seem to cause any issues on my side (using SDK 8.2.1 & CLI 7.1.1). [~hknoechel] can you confirm for me your status on this ticket? Do you still have the problem or did it go away for you?
We workarounded by writing an own native module for date formatting and haven't looked into it again. So no prio for us anymore.
I tested this with the newest Titanium and it doesn't crash on Android. As of Titanium 9.1.0, we added
toLocaleString()
support on Android as well as otherIntl
related APIs. So, I think we can close this. *Side Note:* Doing amyNumber.toFixed(2).toLocaleString()
won't "localize" the number to a string sincetoFixed()
returns a string. You can do the following instead.