cowbell / cordova-plugin-geofence

Geofencing plugin for cordova
Apache License 2.0
264 stars 318 forks source link

ios segfault when entering geo-fence #233

Closed mibzman closed 6 years ago

mibzman commented 7 years ago
Swift Version: 3.1
OSx Version: 10.12.4
iPhone 7+ simulator

when the user enters a geofence the following is written to the log:

GeofencePlugin - Entering region 1
 syslogd[39201]: ASL Sender Statistics
 SpringBoard[39216]: UNSUserNotificationServerConnectionListener connection invalidated
 com.apple.CoreSimulator.SimDevice.F5AD4777-7406-4917-8535-8C708E42C131.launchd_sim[39199] (UIKitApplication:com.myApp.mobile[0x8d96][39221][39554]): Service exited due to Killed: 9
 assertiond[39221]: Deleted job with label: UIKitApplication:com.myApp.mobile[0x8d96][39221]

The offending line is in SwiftData.json:

if let columnType = String(validatingUTF8: sqlite3_column_decltype(pStmt, i))?.uppercased() {

Error:

thread 1: EXEC_BAD_ACCESS (code=1, address=0x163)

note that this is running after following the procedure here, so this is swift 3

mibzman commented 7 years ago

fixed by replacing

if let columnType = String(validatingUTF8: sqlite3_column_decltype(pStmt, i))?.uppercased() {
    if let columnValue: AnyObject = getColumnValue(pStmt!, index: i, type: columnType) {
        row[columnName] = SDColumn(obj: columnValue)
    }
}

with

if let thing = sqlite3_column_decltype(pStmt, i), let columnType = String(validatingUTF8: thing)?.uppercased(){
    if let columnValue: AnyObject = getColumnValue(pStmt!, index: i, type: columnType) {
        row[columnName] = SDColumn(obj: columnValue)
    }
}
mibzman commented 6 years ago

This was caused by differing behavior between ios notifications and android notifications. Ios doesn't do 'titles' in the same way that android does, so if a geofence doesn't have a 'description' it would take a dump.