IndoorAtlas / cordova-plugin

IndoorAtlas Apache Cordova plugin
https://docs.indooratlas.com/cordova/latest
Apache License 2.0
11 stars 14 forks source link

iOS crash - attempt to insert nil object from objects[2] floorPlanToDictionary #42

Closed phasooni closed 3 years ago

phasooni commented 3 years ago

Hi! I have noticed pretty severe error on iOS (14.3 and 14.4) that makes the plugin non-functional. It occurs when switching geofences within a floor plan. I am not an iOS dev, but that's what I was able to capture image

Configuration wise, we have just one floor plan with couple geofences added.

Any help would be highly appreciated as the exception crashes our app entirely. I tried to review these changes https://github.com/IndoorAtlas/cordova-plugin/commit/3012d88885e3f19f127d9506b8a82293c5051ccb#diff-11a0e118bb57c01081d59ef8f4297267c2d38f746ec2e24dcef78f0787c298dd for added geofence support, but I was not able to find the cause.

Thanks!

Tested on the latest plugin version.

phasooni commented 3 years ago

Alright, I think I found the issue. @"url": floorplan.imageUrl.absoluteString, is becoming nil therefore the exception occurs. I think some nil check would be required here.

matti-ida commented 3 years ago

Hi @phasooni, thanks for the report!

We believe the root cause of the crash was a bug in iOS SDK that has been fixed. We just updated the Cordova plugin to version 3.4.0, could you check if that fixes the issue ?

https://github.com/IndoorAtlas/cordova-plugin/releases/tag/3.4.0

phasooni commented 3 years ago

Hi @matti-ida ! Thanks for such a quick response. That's great news. I will review and let you know.

Also, I found that when leaving a floor plan both metersToPixels and pixelsToMeters become NaN so in case it has not been fixed in 3.4.0 an additional check would be required: @(isnan(floorplan.pixelToMeterConversion) ? 0: floorplan.pixelToMeterConversion)

phasooni commented 3 years ago

@matti-ida at first glance it looks like both issues have been resolved. Some further testing will be required, but nonetheless thanks a ton for the support!

I am closing the ticket.

matti-ida commented 3 years ago

Good to hear!