nick92 / flutter_mapbox

Apache License 2.0
6 stars 9 forks source link

Android and iOS issues #11

Closed aleonnet closed 1 year ago

aleonnet commented 1 year ago

Hi @nick92 thanks for the plugin! Simple and effective! iOS is building, but there seem to be an issue with Mapbox autorization as _controller and other variables are null. See below. Would you fix it please?

<< if (!_poisShowing) { _controller!.setPOI(...

Exception has occurred. _TypeError (Null check operator used on a null value)

In XCode [Info, common]: Using Mapbox Common SDK v23.8.3(f7a9d8586) [Info, maps-core]: Using Mapbox Core Maps SDK v10.16.1(4703e9fa8c) [VERBOSE-2:FlutterDarwinContextMetalImpeller.mm(37)] Using the Impeller rendering backend. flutter: The Dart VM service is listening on http://127.0.0.1:49173/QPbFPEdUarM=/ This method can cause UI unresponsiveness if invoked on the main thread. Instead, consider waiting for the -locationManagerDidChangeAuthorization: callback and checking authorizationStatus first.

Flutter Call stack _SampleNavigationAppState.build. (/Users/./Development/mapbox_nav_blehud/lib/map.dart:192) _InkResponseState.handleTap (/Users/./Development/flutter/packages/flutter/lib/src/material/ink_well.dart:1154) GestureRecognizer.invokeCallback (/Users/./Development/flutter/packages/flutter/lib/src/gestures/recognizer.dart:275) TapGestureRecognizer.handleTapUp (/Users/./Development/flutter/packages/flutter/lib/src/gestures/tap.dart:654) BaseTapGestureRecognizer._checkUp (/Users/./Development/flutter/packages/flutter/lib/src/gestures/tap.dart:311) BaseTapGestureRecognizer.handlePrimaryPointer (/Users/./Development/flutter/packages/flutter/lib/src/gestures/tap.dart:244) PrimaryPointerGestureRecognizer.handleEvent (/Users/./Development/flutter/packages/flutter/lib/src/gestures/recognizer.dart:630) PointerRouter._dispatch (/Users/./Development/flutter/packages/flutter/lib/src/gestures/pointer_router.dart:98) PointerRouter._dispatchEventToRoutes. (/Users/./Development/flutter/packages/flutter/lib/src/gestures/pointer_router.dart:143) _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:625) PointerRouter._dispatchEventToRoutes (/Users/./Development/flutter/packages/flutter/lib/src/gestures/pointer_router.dart:141) PointerRouter.route (/Users/./Development/flutter/packages/flutter/lib/src/gestures/pointer_router.dart:127) GestureBinding.handleEvent (/Users/./Development/flutter/packages/flutter/lib/src/gestures/binding.dart:488) GestureBinding.dispatchEvent (/Users/./Development/flutter/packages/flutter/lib/src/gestures/binding.dart:468) RendererBinding.dispatchEvent (/Users/./Development/flutter/packages/flutter/lib/src/rendering/binding.dart:333) GestureBinding._handlePointerEventImmediately (/Users/./Development/flutter/packages/flutter/lib/src/gestures/binding.dart:413) GestureBinding.handlePointerEvent (/Users/./Development/flutter/packages/flutter/lib/src/gestures/binding.dart:376) GestureBinding._flushPointerEventQueue (/Users/./Development/flutter/packages/flutter/lib/src/gestures/binding.dart:323) GestureBinding._handlePointerDataPacket (/Users/./Development/flutter/packages/flutter/lib/src/gestures/binding.dart:292) _invoke1 (/Users/./Development/flutter/bin/cache/pkg/sky_engine/lib/ui/hooks.dart:186)

nick92 commented 1 year ago

is this code from the example map.dart file or have you amended it in some way?

The _controller variable should be initialised on load if options are set on initialisation, so at the point of pressing the 'add poi' button the map should be loaded, are you seeing this or is the map blank?

aleonnet commented 1 year ago

The exact code of map.dart. The map is blank on iOS (On the Android build, the map shows up from the start with no button pressed)

aleonnet commented 1 year ago

@nick92 To improve the feedback.

I've download the current main branch and run the example on both Android and iOS devices.

In Android the app builds from the start, with just one deprecation warning from FlutterLocation.java. Clear route does not alternate to Build route and it causes this behavior 48571 W/Mapbox (30290): [maps-android\Mbgl-RenderThread]: Non-render event could not be run, retrying in 50 ms...Sometimes I got message instructionIndex is Null

In iOS builds after adjustments below but results in map blank and pressing any button results in Exception has occurred. _TypeError (Null check operator used on a null value)

iOS Detail [!] Unable to find a target named RunnerTests in project Runner.xcodeproj, did find Runner. -> Commented this part in Podfile (later we can recreate iOS folder) target 'RunnerTests' do inherit! :search_paths end

Thread 1: "To use location in iOS8 and above you need to define either NSLocationWhenInUseUsageDescription or NSLocationAlwaysUsageDescription in the app bundle's Info.plist file" -> Added this NSLocationAlwaysUsageDescription to Info.plist

No such module 'Flutter'

This method can cause UI unresponsiveness if invoked on the main thread. Instead, consider waiting for the -locationManagerDidChangeAuthorization: callback and checking authorizationStatus first. Type: Fault | Timestamp: 2023-11-08 15:10:54.668787-03:00 | Library: CoreLocation | Subsystem: com.apple.runtime-issues | Category: CoreLocation | TID: 0x23c631

aleonnet commented 1 year ago

Hi @nick92 have you checked the issue? Thanks

nick92 commented 1 year ago

It's odd that the map isn't loading as expected, have you gone through the installation process for mapbox on iOS?

https://docs.mapbox.com/ios/navigation/guides/get-started/install/

aleonnet commented 1 year ago

I rebuild the info.list and it worked. Also included _routeBuilt = false to allow Build/Clear route text to alternate properly.

Thank you!

... ElevatedButton( child: Text(_routeBuilt && !_isNavigating ? "Clear Route" : "Build Route"), onPressed: _isNavigating ? null : () { if (_routeBuilt) { _controller!.clearRoute(); _routeBuilt = false; } else {

...

UIBackgroundModes
<array>
    <string>location</string>
    <string>fetch</string>
    <string>audio</string>
    <string>bluetooth-central</string>
</array>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UISupportedInterfaceOrientations</key>
<array>
    <string>UIInterfaceOrientationPortrait</string>
    <string>UIInterfaceOrientationLandscapeLeft</string>
    <string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
<key>NSLocationWhenInUseUsageDescription</key>
<string>This app needs access to location when open.</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>This app needs access to location when in the background.</string>

aleonnet commented 1 year ago

@nick92 What could be triggering so many map_position_changed events, without even changing or not lat/long? Thanks

CleanShot 2023-11-13 at 13 10 28

nick92 commented 1 year ago

That event is fired when the map is idle i.e. moved and then stropped again, and returns the center lat/long of the map