Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-11055] Android: WebView event JSON object conversion bug causing crash.

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-10-11T23:28:39.000+0000
Affected Version/sRelease 1.8.3
Fix Version/sRelease 3.0.0, Release 3.1.0, 2012 Sprint 21 API, 2012 Sprint 21
ComponentsAndroid
Labelsapi, qe-testadded
ReporterJosh Roesslein
AssigneeJosh Roesslein
Created2012-09-22T14:21:09.000+0000
Updated2013-10-07T09:11:20.000+0000

Description

Firing an event from a WebView will cause a crash if the event object contains a null value. This is due to how we bridge the object between Java <-> WebView as a JSON string. We do not properly convert JSONObject.NULL values back to Java nulls which causes our Kroll layer to crash since it can't convert this type.

Test Case

1. Create an application with the attached app.js and index.html. 2. Click the button in the web view ("click me") to trigger an event. Pass: alert appears displaying the event object. Fail: application crashes due to conversion error ("Unable to convert unknown Java object class 'org.json.JSONObject$1' to Js value")

Credit

Thanks to Tristan Waddington for reporting this bug and the detailed write up on his blog.

Attachments

FileDateSize
app.js2012-10-10T19:13:21.000+0000221
index.html2012-09-22T14:35:54.000+0000356

Comments

  1. Josh Roesslein 2012-09-22

    Created [PR #3032](https://github.com/appcelerator/titanium_mobile/pull/3032) to resolve issue.
  2. Josh Roesslein 2012-10-10

    Updated app.js to fix crash seen when running on Rhino.
  3. Ping Wang 2012-10-11

    backport PR https://github.com/appcelerator/titanium_mobile/pull/3174
  4. Natalie Huynh 2012-12-05

    Tested with 3.0.0.20121204144658 on Droid 1 2.2.3 with Rhino and V8

JSON Source