Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-23672] Android: Hyperloop - A meaningful error message should appear If you try to stringify an object instance

GitHub Issuen/a
TypeImprovement
PriorityMedium
StatusOpen
ResolutionUnresolved
Affected Version/sRelease 5.4.0
Fix Version/sn/a
ComponentsAndroid, Hyperloop
Labelsqe-5.4.0
ReporterWilson Luu
AssigneeJan Vennemann
Created2016-07-21T20:42:25.000+0000
Updated2017-09-22T15:11:12.000+0000

Description

*Details:* Currently with Android Hyperloop, if you try to stringify an object instance, a Uncaught RangeError: Maximum call stack size exceeded runtime error is thrown. This is expected, but the returned error message looks like this:
[ERROR] TiExceptionHandler: (main) [9945,9945] ----- Titanium Javascript Runtime Error -----
[ERROR] TiExceptionHandler: (main) [0,9945] - In ti:/titanium.js:0,0
[ERROR] TiExceptionHandler: (main) [0,9945] - Message: Uncaught RangeError: Maximum call stack size exceeded
[ERROR] TiExceptionHandler: (main) [0,9945] - Source: (function (exports, require, module, __filename, __dirname, Titanium, Ti, glob
[ERROR] V8Exception: Exception occurred at ti:/titanium.js:0: Uncaught RangeError: Maximum call stack size exceeded
[ERROR] V8Exception: RangeError: Maximum call stack size exceeded
On iOS, if you stringify an object instance, you will get back a meaningful error message:
[ERROR] Script Error {
[ERROR]     column = 35;
[ERROR]     line = 14;
[ERROR]     message = "JSON.stringify cannot serialize cyclic structures.";
[ERROR]     sourceURL = "file:///Users/wilson_san/Library/Developer/CoreSimulator/Devices/E0D90275-BCED-43E8-9A05-36D3BBF73A52/data/Containers/Bundle/Application/F53BA1D6-12DA-4D52-A229-D1CDA2B87800/monkey23198.app/alloy/controllers/index.js";
[ERROR]     stack = "stringify@[native code]\ndoClick@file:///Users/wilson_san/Library/Developer/CoreSimulator/Devices/E0D90275-BCED-43E8-9A05-36D3BBF73A52/data/Containers/Bundle/Application/F53BA1D6-12DA-4D52-A229-D1CDA2B87800/monkey23198.app/alloy/controllers/index.js:14:35";
[ERROR] } 
[ERROR] 2016-07-21 13:14:36.120 monkey23198[38836:3930678] Attempting to load the view of a view controller while it is deallocating is not allowed and may result in undefined behavior (<UIAlertController: 0x7fa96bc3a190>)
[TRACE] [monkey23198] Attempting to load the view of a view controller while it is deallocating is not allowed and may result in undefined behavior (<UIAlertController: 0x7fa96bc3a190>)
[ERROR]   
*Steps to reproduce:*

Create a Hylperloop enabled project: appc new

In the index.js, replace the code with this:

var String = require('java.lang.String');

function doClick(e) {
    alert($.label.text);
    var empty = new String();
    console.log(JSON.stringify(empty));
}

$.index.open();

Install the app to an Android device/emulator: appc run -p android

*Actual:* A RangeError: Maximum call stack size exceeded runtime error is thrown; see above for stack trace. *Expected:* A meaningful message should appear for Android, similar to iOS.

Comments

No comments

JSON Source