Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-16562] Android: Kroll bridge passing null/undefined values can throw exceptions when passed to TiConvert methods

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2014-10-27T18:55:46.000+0000
Affected Version/sRelease 3.2.0, Release 3.2.1
Fix Version/sRelease 3.4.1, Release 3.4.2, Release 3.5.0, Release 4.0.0
ComponentsAndroid
Labelsmodule_androidmapv2, qe-manualtest, qe-testadded, supportTeam
ReporterMostafizur Rahman
AssigneeAllen Yeung
Created2014-03-06T10:18:03.000+0000
Updated2014-11-21T18:49:21.000+0000

Description

Problem Description

Exception is thrown when passing objects with null/undefined values for expected keys values on Android. Ti.map.TiUIMapView passes this null value to TiConvert.toDouble which causes then throws a NullPointerException. Here is an example piece of code when setting a map region. This works fine on iOS:
function setup(event) {

 $.map.region = {
   latitude: 36,
   longitude: -78,
   latitudeDelta: null,
   longitudeDelta: null
 };
}
Here is the exception on Android:
[ERROR] :  TiApplication: (main) [1830,1830] Sending event: exception on thread: main msg:java.lang.NullPointerException; Titanium 3.2.0,2013/12/20 10:57,d9182d6
[ERROR] :  TiApplication: java.lang.NullPointerException
[ERROR] :  TiApplication:   at org.appcelerator.titanium.util.TiConvert.toDouble(TiConvert.java:527)
[ERROR] :  TiApplication:   at org.appcelerator.titanium.util.TiConvert.toDouble(TiConvert.java:540)
[ERROR] :  TiApplication:   at ti.map.TiUIMapView.updateCamera(TiUIMapView.java:247)
[ERROR] :  TiApplication:   at ti.map.TiUIMapView.propertyChanged(TiUIMapView.java:171)
[ERROR] :  TiApplication:   at org.appcelerator.kroll.KrollPropertyChange.fireEvent(KrollPropertyChange.java:21)
[ERROR] :  TiApplication:   at org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1059)
[ERROR] :  TiApplication:   at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:329)
[ERROR] :  TiApplication:   at ti.map.ViewProxy.handleMessage(ViewProxy.java:150)
[ERROR] :  TiApplication:   at android.os.Handler.dispatchMessage(Handler.java:95)
[ERROR] :  TiApplication:   at android.os.Looper.loop(Looper.java:158)
[ERROR] :  TiApplication:   at android.app.ActivityThread.main(ActivityThread.java:5789)
[ERROR] :  TiApplication:   at java.lang.reflect.Method.invokeNative(Native Method)
[ERROR] :  TiApplication:   at java.lang.reflect.Method.invoke(Method.java:525)
[ERROR] :  TiApplication:   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027)
[ERROR] :  TiApplication:   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:843)
[ERROR] :  TiApplication:   at dalvik.system.NativeStart.main(Native Method)

This the kroll bridge should either ignore null/undefined values or have each have maps module defensively check for null values. I've attached a project showcases the error.

Attachments

FileDateSize
ErrorScreenShot.png2014-08-21T17:45:03.000+000091776
krollBridge.zip2014-03-06T10:25:45.000+0000757617

Comments

  1. Ingo Muschenetz 2014-03-10

    This I believe will be fixed in the maps module, however, the fix will be that we are more defensive of Null values. Instead, they should use a default value of 0 for lat/long instead of null.
  2. Ingo Muschenetz 2014-05-01

    Since the fix is in the maps module, it does not need to go out with 3.3.0
  3. Allen Yeung 2014-07-18

    PR for TIMOB: https://github.com/appcelerator/titanium_mobile/pull/5917 ti.map PR: https://github.com/appcelerator-modules/ti.map/pull/45 Test steps: 1. Create a project and use the example code from the ti.map module (You will need to copy all the relevant code and resources from the examples dir of the map module.) 2. Inside the annotations.js file, change all the values of latitude, longitude, latitudeDelta, longitudeDelta values to null 3. Run the example code, and verify that the annotations section does not crash
  4. Ewan Harris 2014-08-21

    The problems still exists on: Mac OSX 10.9.4 Appcelerator Studio, build: 3.4.0.201408201526 Titanium SDK build: 3.4.0.v20140820125714 Titanium CLI, build: 3.4.0-dev Alloy: 1.5.0-dev Using the ti.Map 2.1.4 module example code, I changed all latitude, longitude, latitudeDelta, longitudeDelta values to null and obtained the error shown in the attached screenshot. Reopening the issue.
  5. Ingo Muschenetz 2014-08-27

    Moving into 3.5.0 as this relies on updating the map as well. Does [~eharris] need to test with ti.map 2.1.6+?
  6. Allen Yeung 2014-08-29

    Yes, this needs to be tested with 2.1.6+ for ti.map
  7. Jon Alter 2014-08-29

    Here is a link to ti.map 2.2.0 (just click on "Raw" to download): https://github.com/appcelerator-modules/ti.map/blob/master/android/dist/ti.map-android-2.2.0.zip
  8. Ewan Harris 2014-08-29

    Verified fix on: Mac OSX 10.9.4 Appcelerator Studio, build: 3.4.0.201408291421 Titanium SDK build: 3.4.0.v20140829104912 Titanium CLI, build: 3.4.0-dev Alloy: 1.5.0-dev ti.map 2.2.0 Android Emulator 4.4.2 Android Device S4 (4.0.4) Using ti.map 2.2.0 took the code from the example folder changed all latitude, longitude, latitudeDelta, longitudeDelta values to null and opened the annotations section. The app does not crash. Closing ticket.
  9. Ingo Muschenetz 2014-10-23

    We _might_ be fixing this in 3.4.1 with an updated map module. Adding to 3.4.1 to confirm.
  10. Ewan Harris 2014-10-27

    Verified fix on: Mac OSX 10.10 Appcelerator Studio, build: 3.4.1.201410191611 Titanium SDK build: 3.4.1.v20141024151719 Titanium CLI, build: 3.4.1-dev Alloy: 1.5.1 ti.map 2.2.1 Android Device S5 (4.4.2) Using ti.map 2.2.1 took the example code and change the latitude, longitude, latitudeDelta, longitudeDelta to null and opened the annotations section, the app does not crash. Closing ticket.

JSON Source