cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shazron Abdullah (JIRA)" <>
Subject [jira] [Commented] (CB-11737) cordova-ios crash in case of Infinity value in result
Date Tue, 23 Aug 2016 18:39:20 GMT


Shazron Abdullah commented on CB-11737:

I did some experiments last night on this. Yes, that is true the JSON spec does not support
these values, and recommend that when stringifying these values, to convert them to null.
What does Windows do in this case, what do they convert to?

Three approaches:
1. Have a try catch, and reject the serialization attempt, report the error. Let plugin developers
develop their own way to serialize this case -- not sure this is feasible. At least the app
won't crash, but then the app will be in an indeterminate state.
2. Serialize Infinity and NaN to the string values "Infinity" and "NaN". These in JavaScript
can be coerced into the right values of Infinity and NaN. However, deserialization is a problem.
3. Serialize Infinity and NaN to null.  Again, deserialization is a problem.

For 2 and 3, deserialization may be only a problem for the unit tests with mixed data to test
whether the serialization worked. 

Also, for these two cases, we would have to iterate through everything in the object to serialize
to determine if it is a NSNumber (INFINITY or NAN) and explicitly convert it to the desired
value. This may or may not have a performance impact, depending on how deep objects are nested
(for NSDictionarys for example) - in UIWebView this process is synchronous (and needs to be
on the main thread).

> cordova-ios crash in case of Infinity value in result
> -----------------------------------------------------
>                 Key: CB-11737
>                 URL:
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: iOS
>            Reporter: Chris Brody
>            Assignee: Shazron Abdullah
> In case an iOS plugin attempts to return a JSON result with an Infinity value it will
crash with NSInvalidArgumentException. I discovered this when investigating this issue:
> Similar to: CB-9435

This message was sent by Atlassian JIRA

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message