transistorsoft / react-native-background-geolocation

Sophisticated, battery-conscious background-geolocation with motion-detection
http://shop.transistorsoft.com/pages/react-native-background-geolocation
MIT License
2.65k stars 426 forks source link

Crash when initiating ready. (unrecognized selector sent to instance) #1259

Closed ArjenLammers closed 3 years ago

ArjenLammers commented 3 years ago

Your Environment

{ locationAuthorizationRequest: 'Always', fastestLocationUpdateInterval: 300000, url: 'http://192.168.1.XX:8080/rest/event/v1/event/add', geofenceModeHighAccuracy: true, disableStopDetection: true, geofenceProximityRadius: 1000, maxRecordsToPersist: -1, debug: true, preventSuspend: false, batchSync: true, useSignificantChangesOnly: false, disableElasiticity: false, showsBackgroundLocationIndicator: true, disableLocationAuthorizationAlert: false, logLevel: 4, method: 'POST', stopDetectionDelay: 0, desiredAccuracy: -1, stopTimeout: 5, geofenceTemplate: '', deferTime: 0, foregroundService: true, elasticityMultiplier: 1, params: '', stationaryRadius: 25, stopOnTerminate: false, desiredOdometerAccuracy: 100, locationOrderDirection: 'ASC', activityType: 1, httpRootProperty: 'location', maxBatchSize: 1, schedule: '', logMaxDays: 3, locationTemplate: '', startOnBoot: true, geofenceInitialTriggerEntry: true, extras: '', autoSyncThreshold: 0, headers: { Token: 'XXXXX' }, maxDaysToPersist: 10, stopOnStationary: false, allowIdenticalLocations: true, locationUpdateInterval: 450000, autoSync: true, heartbeatInterval: 60, enableHeadless: false, stopAfterElapsedMinutes: 0, distanceFilter: 0, httpTimeout: 60000 }


## Expected Behavior
<!--- Tell us what should happen -->
Initialize, and start monitoring location every 15 mins.

## Actual Behavior
<!--- Tell us what happens instead -->
The app fully crashed, leaving this in the log output in XCode:

021-03-09 11:02:41.967622+0100 NativeTemplateDev[503:159044] -[__NSCFConstantString isEqualToDictionary:]: unrecognized selector sent to instance 0x1e0fc7650
2021-03-09 11:02:41.967768+0100 NativeTemplateDev[503:159044] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFConstantString isEqualToDictionary:]: unrecognized selector sent to instance 0x1e0fc7650'
*** First throw call stack:
(0x18f7899d8 0x1a3b0fb54 0x18f699bbc 0x18f78c01c 0x18f78df8c 0x100f474c8 0x100f492a8 0x100f47960 0x100f473c4 0x100f478c0 0x100f49104 0x10078b780 0x10299fce4 0x1029a1528 0x1029af994 0x18f7095e0 0x18f703a88 0x18f702ba0 0x1a646b598 0x191ff42f4 0x191ff9874 0x1005f98d4 0x18f3e1568)
libc++abi.dylib: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFConstantString isEqualToDictionary:]: unrecognized selector sent to instance 0x1e0fc7650'
terminating with uncaught exception of type NSException

Readable steps in the thread stack trace are:

- TSConfig updateWithDictionary
- TSConfigBuilder eachProperty
- TSConfigBuilder eachDirtyProperty
- TSConfig updateWithDictionary
- TSConfigBuilder value:isEqualTo:withType

I'm using the same configuration on Android (same RN and library version), which runs fine.

## Steps to Reproduce
<!--- reproduce this issue; include code to reproduce, if relevant -->
1. 
2.
3.
4.

## Context
<!--- What were you trying to do? -->

## Debug logs
<!-- include iOS / Android logs
- ios XCode logs,
- use #getLog #emailLog methods (@see docs)
- Android: $ adb logcat -s TSLocationManager
-->
<details><summary>Logs</summary>

``` <!-- Syntax highlighting:  DO NOT REMOVE -->
PASTE_YOUR_LOGS_HERE

getLog doesn't return anything.
XCode has the following logs:

2021-03-09 11:02:31.881894+0100 NativeTemplateDev[503:159044] [TSBackgroundFetch load]: (
)
2021-03-09 11:02:31.882256+0100 NativeTemplateDev[503:159044] [TSBGAppRefreshSubscriber load]: {
}
2021-03-09 11:02:38.919521+0100 NativeTemplateDev[503:159060] [connection] nw_socket_handle_socket_event [C2.1:1] Socket SO_ERROR [61: Connection refused]
2021-03-09 11:02:38.920226+0100 NativeTemplateDev[503:159060] [connection] nw_socket_handle_socket_event [C2.2:1] Socket SO_ERROR [61: Connection refused]
2021-03-09 11:02:38.920645+0100 NativeTemplateDev[503:159061] [connection] nw_connection_get_connected_socket [C2] Client called nw_connection_get_connected_socket on unconnected nw_connection
2021-03-09 11:02:38.921140+0100 NativeTemplateDev[503:159061] TCP Conn 0x283194630 Failed : error 0:61 [61]
2021-03-09 11:02:38.931870+0100 NativeTemplateDev[503:159044] -[RNFirebase init] [Line 18] Setting up RNFirebase instance
2021-03-09 11:02:38.933692+0100 NativeTemplateDev[503:159060] 7.7.0 - [Firebase/Core][I-COR000005] No app has been configured yet.
2021-03-09 11:02:38.937 [info][tid:main][SQLite.m:78] Initializing SQLitePlugin
2021-03-09 11:02:38.938 [info][tid:main][SQLite.m:89] Detected docs path: /var/mobile/Containers/Data/Application/068773C8-1016-46A0-8CBD-065750BC011F/Documents
2021-03-09 11:02:38.938 [info][tid:main][SQLite.m:93] Detected Library path: /var/mobile/Containers/Data/Application/068773C8-1016-46A0-8CBD-065750BC011F/Library
2021-03-09 11:02:38.938 [info][tid:main][SQLite.m:100] no cloud sync at path: /var/mobile/Containers/Data/Application/068773C8-1016-46A0-8CBD-065750BC011F/Library/LocalDatabase
2021-03-09 11:02:40.425 [info][tid:com.facebook.react.JavaScript] Running "App" with {"rootTag":1,"initialProps":{}}
2021-03-09 11:02:40.675 [info][tid:com.facebook.react.SQLiteQueue][SQLite.m:197] target database location: nosync
2021-03-09 11:02:40.675 [info][tid:com.facebook.react.SQLiteQueue][SQLite.m:208] Opening db in mode READ_WRITE, full path: /var/mobile/Containers/Data/Application/068773C8-1016-46A0-8CBD-065750BC011F/Library/LocalDatabase/default
2021-03-09 11:02:40.676 [info][tid:com.facebook.react.SQLiteQueue][SQLite.m:235] Database opened
2021-03-09 11:02:40.676 [info][tid:com.facebook.react.SQLiteQueue][SQLite.m:249] Good news: SQLite is thread safe!
2021-03-09 11:02:40.676 [info][tid:com.facebook.react.SQLiteQueue][SQLite.m:255] open cb finished ok
2021-03-09 11:02:41.121 [info][tid:main][RNGestureHandlerManager.m:136] [GESTURE HANDLER] Initialize gesture handler for root view <RCTRootContentView: 0x102b1b8a0; reactTag: 1; frame = (0 0; 375 667); gestureRecognizers = <NSArray: 0x2808053e0>; layer = <CALayer: 0x28003c8a0>>
2021-03-09 11:02:41.181 [tid:com.facebook.react.JavaScript] Received object '15199648742375425' for widget Tracker.Native_User.dataView1
2021-03-09 11:02:41.344 [info][tid:com.facebook.react.JavaScript] [location] Stopping Background Geolocation...
2021-03-09 11:02:41.354052+0100 NativeTemplateDev[503:159060] [TSBackgroundFetch removeListener] WARNING:  Failed to find listener for identifier: TSLocationManager
2021-03-09 11:02:41.602 [info][tid:com.facebook.react.JavaScript] [location] Removing geofences..
2021-03-09 11:02:41.617 [info][tid:com.facebook.react.JavaScript] [location] Stopped.
2021-03-09 11:02:41.653 [info][tid:com.facebook.react.JavaScript] [location] Geofences removed...
2021-03-09 11:02:41.918 [info][tid:com.facebook.react.JavaScript] [location] Adding 1 geofences.
2021-03-09 11:02:41.952 [info][tid:com.facebook.react.JavaScript] '[location] Initializing using config: ', { locationAuthorizationRequest: 'Always',
  fastestLocationUpdateInterval: 300000,
  url: 'http://192.168.1.XX:8080/rest/event/v1/event/add',
  geofenceModeHighAccuracy: true,
  disableStopDetection: true,
  geofenceProximityRadius: 1000,
  maxRecordsToPersist: -1,
  debug: true,
  preventSuspend: false,
  batchSync: true,
  useSignificantChangesOnly: false,
  disableElasiticity: false,
  showsBackgroundLocationIndicator: true,
  disableLocationAuthorizationAlert: false,
  logLevel: 4,
  method: 'POST',
  stopDetectionDelay: 0,
  desiredAccuracy: -1,
  stopTimeout: 5,
  geofenceTemplate: '',
  deferTime: 0,
  foregroundService: true,
  elasticityMultiplier: 1,
  params: '',
  stationaryRadius: 25,
  stopOnTerminate: false,
  desiredOdometerAccuracy: 100,
  locationOrderDirection: 'ASC',
  activityType: 1,
  httpRootProperty: 'location',
  maxBatchSize: 1,
  schedule: '',
  logMaxDays: 3,
  locationTemplate: '',
  startOnBoot: true,
  geofenceInitialTriggerEntry: true,
  extras: '',
  autoSyncThreshold: 0,
  headers: { Token: ‘XXXXXXXXX’ },
  maxDaysToPersist: 10,
  stopOnStationary: false,
  allowIdenticalLocations: true,
  locationUpdateInterval: 450000,
  autoSync: true,
  heartbeatInterval: 60,
  enableHeadless: false,
  stopAfterElapsedMinutes: 0,
  distanceFilter: 0,
  httpTimeout: 60000 }
2021-03-09 11:02:41.959 [info][tid:com.facebook.react.JavaScript] [location] Geofences added.
2021-03-09 11:02:41.967622+0100 NativeTemplateDev[503:159044] -[__NSCFConstantString isEqualToDictionary:]: unrecognized selector sent to instance 0x1e0fc7650
2021-03-09 11:02:41.967768+0100 NativeTemplateDev[503:159044] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFConstantString isEqualToDictionary:]: unrecognized selector sent to instance 0x1e0fc7650'
*** First throw call stack:
(0x18f7899d8 0x1a3b0fb54 0x18f699bbc 0x18f78c01c 0x18f78df8c 0x100f474c8 0x100f492a8 0x100f47960 0x100f473c4 0x100f478c0 0x100f49104 0x10078b780 0x10299fce4 0x1029a1528 0x1029af994 0x18f7095e0 0x18f703a88 0x18f702ba0 0x1a646b598 0x191ff42f4 0x191ff9874 0x1005f98d4 0x18f3e1568)
libc++abi.dylib: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFConstantString isEqualToDictionary:]: unrecognized selector sent to instance 0x1e0fc7650'
terminating with uncaught exception of type NSException

christocracy commented 3 years ago

Why are you providing empty string to a bunch of properties which are defined as Object?

Eg: params: ''. That requires an {}!

You're doing that multiple times.

MaxKicw commented 3 years ago

I fixed this issue through: yarn add react-native-background-fetch@4.0.1.

Found the changelog of Chris here: https://github.com/transistorsoft/react-native-background-fetch/blob/master/CHANGELOG.md

Hope it helps.

ArjenLammers commented 3 years ago

Hi, thanks for the fast response. Changing the configuration to

{ locationAuthorizationRequest: 'Always', fastestLocationUpdateInterval: 300000, url: 'http://192.168.1.XX:8080/rest/event/v1/event/add', geofenceModeHighAccuracy: true, disableStopDetection: true, geofenceProximityRadius: 1000, maxRecordsToPersist: -1, debug: true, batchSync: true, showsBackgroundLocationIndicator: true, logLevel: 4, method: 'POST', stopDetectionDelay: 0, desiredAccuracy: -1, stopTimeout: 5, deferTime: 0, foregroundService: true, elasticityMultiplier: 1, stationaryRadius: 25, desiredOdometerAccuracy: 100, locationOrderDirection: 'ASC', activityType: 1, httpRootProperty: 'location', maxBatchSize: 1, logMaxDays: 3, startOnBoot: true, geofenceInitialTriggerEntry: true, autoSyncThreshold: 0, headers: { Token: ‘XXXXXXX’ }, maxDaysToPersist: 10, allowIdenticalLocations: true, locationUpdateInterval: 450000, autoSync: true, heartbeatInterval: 60, stopAfterElapsedMinutes: 0, distanceFilter: 0, httpTimeout: 60000 }

Made the library work. Not sure which specific setting was the culprit.