GitHub Issue | n/a |
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2014-10-27T18:55:46.000+0000 |
Affected Version/s | Release 3.2.0, Release 3.2.1 |
Fix Version/s | Release 3.4.1, Release 3.4.2, Release 3.5.0, Release 4.0.0 |
Components | Android |
Labels | module_androidmapv2, qe-manualtest, qe-testadded, supportTeam |
Reporter | Mostafizur Rahman |
Assignee | Allen Yeung |
Created | 2014-03-06T10:18:03.000+0000 |
Updated | 2014-11-21T18:49:21.000+0000 |
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.
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.
Since the fix is in the maps module, it does not need to go out with 3.3.0
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
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.
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+?
Yes, this needs to be tested with 2.1.6+ for ti.map
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
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.
We _might_ be fixing this in 3.4.1 with an updated map module. Adding to 3.4.1 to confirm.
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.