Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type exception (int/bool subtype) when targeting iOS device (10.3.3) #111

Closed
leetworx opened this issue Aug 25, 2019 · 22 comments
Closed

Type exception (int/bool subtype) when targeting iOS device (10.3.3) #111

leetworx opened this issue Aug 25, 2019 · 22 comments
Labels
bug Something isn't working stale

Comments

@leetworx
Copy link
Contributor

Your Environment

  • Plugin version: 1.2.1
  • Platform: iOS
  • OS version: 10.3.3
  • Device manufacturer / model: iPhone 5c
  • Flutter info (flutter doctor):

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, v1.9.3-pre.49, on Mac OS X 10.14.5 18F132, locale en-CA)

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 10.2.1)
[✓] Android Studio (version 3.2)
[✓] Connected device (3 available)

• No issues found!

  • Plugin config:
    bg.BackgroundGeolocation.ready(bg.Config(
            desiredAccuracy: bg.Config.DESIRED_ACCURACY_NAVIGATION,
            distanceFilter: 10.0,
            preventSuspend: true,
            heartbeatInterval: 60,
            debug: true,
            logLevel: bg.Config.LOG_LEVEL_DEBUG,
            reset: true))

Expected Behavior

flutter run -d
should build/install run app on device

Actual Behavior

appears to get an error regarding int/bool types related to state config

Steps to Reproduce

  1. flutter clean
    2.flutter run -d

Context

build/run app on physical iOS device (iPhone 5c)

Debug logs

Logs

Running pod install... 25.1s
Running Xcode build...

├─Assembling Flutter resources... 13.5s
└─Compiling, linking and signing... 44.3s
Xcode build done. 184.6s
Configuring the default Firebase app...
Configured the default Firebase app __FIRAPP_DEFAULT.
Installing and launching... 63.4s
Syncing files to device Todd’s iPhone...
flutter: [providerchange] - [ProviderChangeEvent enabled:true, status: 3, network: true, gps: true]
[VERBOSE-2:ui_dart_state.cc(148)] Unhandled Exception: type 'int' is not a subtype of type 'bool' #0 new State (package:flutter_background_geolocation/models/state.dart:49:36) #1 BackgroundGeolocation.ready (package:flutter_background_geolocation/background_geolocation.dart:215:16)
#2 _StateWidgetState.initLocationPlugin (package:yelobus/state_widget.dart:162:30) #3 _AsyncAwaitCompleter.start (dart:async-patch/async_patch.dart:43:6) #4 _StateWidgetState.initLocationPlugin (package:yelobus/state_widget.dart:82:34) #5 _StateWidgetState.initState (package:yelobus/state_widget.dart:49:5) #6 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4061:58) #7 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3912:5) #8 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3094:14) #9 Element.updateChild (package:flutter/src/widgets/framework.dart:2897:12) #10 RenderObjectToWidgetElement._rebuild (package:flutter/src/widgets/binding.dart:1011:16) #11 RenderObjectToWidgetElement.mount (package:flutter/src/widgets/binding.dart:982:5) #12 RenderObjectToWidgetAdapter.attachToRenderTree. (package:flutter/src/widgets/binding.dart:928:17)
#13 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2321:19) #14 RenderObjectToWidgetAdapter.attachToRenderTree (package:flutter/src/widgets/binding.dart:927:13) #15 WidgetsBinding.attachRootWidget (package:flutter/src/widgets/binding.dart:808:7) #16 runApp (package:flutter/src/widgets/binding.dart:858:7) #17 main (package:yelobus/main.dart:10:3) #18 _runMainZoned.. (dart:ui/hooks.dart:229:25) #19 _rootRun (dart:async/zone.dart:1124:13) #20 _CustomZone.run (dart:async/zone.dart:1021:19) #21 _runZoned (dart:async/zone.dart:1516:10) #22 runZoned (dart:async/zone.dart:1500:12) #23 _runMainZoned. (dart:ui/hooks.dart:221:5) #24 _startIsolate. (dart:isolate-patch/isolate_patch.dart:305:19) #25 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:172:12) flutter: [location] - [Location {odometer: 0.0, is_moving: false, battery: {level: -1.0, is_charging: false}, coords: {altitude: 239.9, floor: null, speed: -1.0, latitude: 43.202435788257105, longitude: -79.99613660856787, accuracy: 65.0, altitude_accuracy: 10.0, heading: -1.0}, sample: true, timestamp: 2019-08-25T01:16:16.343Z, extras: {}, activity: {type: unknown, confidence: 100}, uuid: 1464C74A-10AA-4023-81F5-C7C5FF56BDB0}]
flutter: [location] - [Location {odometer: 0.0, is_moving: false, battery: {level: -1.0, is_charging: false}, coords: {altitude: 239.9, floor: null, speed: -1.0, latitude: 43.202435788257105, longitude: -79.99613660856787, accuracy: 65.0, altitude_accuracy: 10.0, heading: -1.0}, sample: true, timestamp: 2019-08-25T01:16:16.390Z, extras: {}, activity: {type: unknown, confidence: 100}, uuid: 02BD3C9C-C0EE-4585-BB24-045E10BC8301}]
flutter: [location] - [Location {odometer: 0.0, is_moving: false, battery: {level: -1.0, is_charging: false}, coords: {altitude: 239.9, floor: null, speed: -1.0, latitude: 43.20243723743637, longitude: -79.99613977505673, accuracy: 65.0, altitude_accuracy: 10.0, heading: -1.0}, extras: {}, timestamp: 2019-08-25T01:16:16.732Z, activity: {type: unknown, confidence: 100}, uuid: 78B6563E-F930-4871-98DB-11CB8A49C1C3}]
Could not update files on device: OS Error: Connection reset by peer, errno = 54

Note that _StateWidgetState.initLocationPlugin (package:yelobus/state_widget.dart:162:30) is the call to bg.BackgroundGeolocation.ready(bg.Config

@leetworx leetworx changed the title Build error when targeting iOS device (10.3.3) Type exception (int/bool subtype) when targeting iOS device (10.3.3) Aug 25, 2019
@christocracy
Copy link
Member

christocracy commented Aug 25, 2019

Edit the plugin's libs/models/State.dart: Comment-out line 49. I suspect it will fail again at line 59. It would seem that iOS 10 is failing to render iOS YES / NO (which are 1/0)

@christocracy
Copy link
Member

And I see you're on Flutter (Channel master, v1.9.3-pre.49, on Mac OS X 10.14.5 18F132, locale en-CA).

I'm on [✓] Flutter (Channel stable, v1.7.8+hotfix.4, on Mac OS X 10.14.5 18F132, locale en-CA)

@leetworx
Copy link
Contributor Author

Thanks for the quick response Chris - I've backed down to 1.7.8+ but I still see the type exception

[VERBOSE-2:ui_dart_state.cc(148)] Unhandled Exception: type 'int' is not a subtype of type 'bool'
#0 new State (package:flutter_background_geolocation/models/state.dart:49:36)
#1 BackgroundGeolocation.ready (package:flutter_background_geolocation/background_geolocation.dart:215:16)

#2 _StateWidgetState.initLocationPlugin (package:yelobus/state_widget.dart:162:30)
#3 _AsyncAwaitCompleter.start (dart:async-patch/async_patch.dart:49:6)
#4 _StateWidgetState.initLocationPlugin (package:yelobus/state_widget.dart:82:34)
#5 _StateWidgetState.initState (package:yelobus/state_widget.dart:49:5)
#6 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4033:58)
#7 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3902:5)
#8 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3084:14)
#9 Element.updateChild (package:flutter/src/widgets/framework.dart:2887:12)
#10 RenderObjectToWidgetElement._rebuild (package:flutter/src/widgets/binding.dart:939:16)
#11 RenderObjectToWidgetElement.mount (package:flutter/src/widgets/binding.dart:910:5)
#12 RenderObjectToWidgetAdapter.attachToRenderTree. (package:flutter/src/widgets/binding.dart:856:17)
#13 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2320:19)
#14 RenderObjectToWidgetAdapter.attachToRenderTree (package:flutter/src/widgets/binding.dart:855:13)
#15 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.attachRootWidget (package:flutter/src/widgets/binding.dart:736:7)
#16 runApp (package:flutter/src/widgets/binding.dart:786:7)
#17 main (package:yelobus/main.dart:10:3)
#18 _runMainZoned.. (dart:ui/hooks.dart:216:25)
#19 _rootRun (dart:async/zone.dart:1124:13)
#20 _CustomZone.run (dart:async/zone.dart:1021:19)
#21 _runZoned (dart:async/zone.dart:1516:10)
#22 runZoned (dart:async/zone.dart:1500:12)
#23 _runMainZoned. (dart:ui/hooks.dart:208:5)
#24 _startIsolate. (dart:isolate-patch/isolate_patch.dart:301:19)
#25 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:172:12)
flutter: [location] - [Location {odometer: 0.0, is_moving: false, battery: {level: -1.0, is_charging: false}, coords: {altitude: 240.0, floor: null, speed: -1.0, latitude: 43.20245572938143, longitude: -79.99606935706692, accuracy: 65.0, altitude_accuracy: 10.0, heading: -1.0}, sample: true, timestamp: 2019-08-25T02:21:23.614Z, extras: {}, activity: {type: unknown, confidence: 100}, uuid: AE07BE4B-67F8-41CC-ADA2-5A9DAFCB20F1}]
flutter: [location] - [Location {odometer: 0.0, is_moving: false, battery: {level: -1.0, is_charging: false}, coords: {altitude: 240.0, floor: null, speed: -1.0, latitude: 43.20245572938143, longitude: -79.99606935706692, accuracy: 65.0, altitude_accuracy: 10.0, heading: -1.0}, sample: true, timestamp: 2019-08-25T02:21:23.621Z, extras: {}, activity: {type: unknown, confidence: 100}, uuid: 89B533FC-127F-4E3D-8D8E-34ED92C34169}]
flutter: [location] - [Location {odometer: 0.0, is_moving: false, battery: {level: -1.0, is_charging: false}, coords: {altitude: 240.0, floor: null, speed: -1.0, latitude: 43.20245572938143, longitude: -79.99606935706692, accuracy: 65.0, altitude_accuracy: 10.0, heading: -1.0}, extras: {}, timestamp: 2019-08-25T02:21:23.636Z, activity: {type: unknown, confidence: 100}, uuid: B79AD828-8EFF-4CCA-88DF-8C5D5359C9F1}]
Syncing files to device Todd’s iPhone...
5,341ms (!)

🔥 To hot reload changes while running, press "r". To hot restart (and rebuild state), press "R".
An Observatory debugger and profiler on Todd’s iPhone is available at: http://127.0.0.1:1048/x6T3ZmiD5Gk=/
For a more detailed help message, press "h". To detach, press "d"; to quit, press "q".
Lost connection to device.
leetbook2:yelobus_mobile leet$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel unknown, v1.7.8+hotfix.4, on Mac OS X 10.14.5 18F132, locale en-CA)

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 10.2.1)
[✓] iOS tools - develop for iOS devices
[✓] Chrome - develop for the web
[✓] Android Studio (version 3.2)
[✓] Connected device (5 available)

• No issues found!

Will try going through the state source and comment out as suggested to see if it can get by.

@christocracy
Copy link
Member

christocracy commented Aug 25, 2019

in lib/background_geolocation.dart, I'm interested in seeing the raw data provided by iOS before State is instantiated.

Put this in there: here it's a bool. I'm guessing on your device it's an int (probably 0).

static Future<State> ready(Config config) async {
    Map state = await _methodChannel.invokeMethod('ready', config.toMap());
+   print("*************** BEFORE new State: disableElasticity: ${state['disableElasticity']}");
    return new State(state);
}
flutter: *************** BEFORE new State: disableElasticity: false

Also, see if you can reproduce this on iOS 12 sim (I doubt you will).

@leetworx
Copy link
Contributor Author

Hey Chris,

Looks like your suspicions are correct - here's the output from the snippet:

flutter: *************** BEFORE new State: disableElasticity: 0

And yes, running this on an iPhone XR (12.2) in the simulator (or my Android device...), no problem.

Wondering if this is a case of finding a new lower bound on system requirements for the plugin or do you see it as something that is resolvable in the near term?

@christocracy
Copy link
Member

It can be supported by doing something like this, checking the .runTimeType to turn int to bool.

@leetworx
Copy link
Contributor Author

This seems to resolve the runtime type issue - looks like I can't create a PR directly, but here's a patch file (.txt) in case you find it helpful. BTW - great plugin, really enjoying getting to know my way around.

0001-fix-runtime-type-issue-int-bool-found-on-older-physi.patch.txt

@christocracy
Copy link
Member

Of course a pr can be made directly, but I’ve already provided int checks for all bool params. Will be pushed tomorrow.

@leetworx
Copy link
Contributor Author

I mean no write for branch creation (I looked) - suppose I could fork. Regardless, thanks for the update.

@christocracy
Copy link
Member

Yes, that’s how github PR workflow generally works. You fork then submit PR back.

@christocracy christocracy added the bug Something isn't working label Aug 26, 2019
@christocracy
Copy link
Member

Try installing from master. See README Installing from Git

@leetworx
Copy link
Contributor Author

Verified - thanks!

@leetworx
Copy link
Contributor Author

FYI, just noticed an additional runtime type buried in the logs - line 138: e.g

        enableTimestampMeta: (data['enableTimestampMeta'].runtimeType == int)
    	? (data['enableTimestampMeta'] != 0)
    	: data['enableTimestampMeta'],

Oddly, it didn't appear to be fatal when I was running on validation (but then I'm battling an unrelated cloud firestore issue - so it may have gotten buried.

@christocracy
Copy link
Member

Re-install from master. I've created some helper methods _ensureBool, _ensureInt and _ensureDouble to help manage things.

@christocracy
Copy link
Member

Let me know if current master is all good for you.

@leetworx
Copy link
Contributor Author

Check - looks great, thanks!

@leetworx
Copy link
Contributor Author

leetworx commented Mar 2, 2020

Just FYI, pulled out my old iPhone 5c for testing a build and this cropped up again, so you may want to reopen.

Looks like the state fields for 'disableAutoSyncOnCellular' and 'encrypt' require the _ensureBool wrapper.

@christocracy
Copy link
Member

Damn. I’m on vacation until next week.

@christocracy christocracy reopened this Mar 2, 2020
leetworx added a commit to leetworx/flutter_background_geolocation that referenced this issue Mar 3, 2020
results in crash on physical iOS device (iPhone 5c)

issue transistorsoft#111
@leetworx
Copy link
Contributor Author

leetworx commented Mar 3, 2020

Hey Chris - put up a small PR in case that helps.
Verified this works as expected on the iPhone 5c

@christocracy
Copy link
Member

christocracy commented Mar 3, 2020 via email

@stale
Copy link

stale bot commented May 2, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You may also mark this issue as a "discussion" and I will leave this open.

@stale stale bot added the stale label May 2, 2020
@stale
Copy link

stale bot commented May 9, 2020

Closing this issue after a prolonged period of inactivity. Fell free to reopen this issue, if this still affecting you.

@stale stale bot closed this as completed May 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stale
Projects
None yet
Development

No branches or pull requests

2 participants