eopeter / flutter_mapbox_navigation

Turn By Turn Navigation for Your Flutter Application
Apache License 2.0
207 stars 161 forks source link

i have a driving app that use google_maps and mapbox navigation as a navigation map but my app crash when the mapbox navigation is called 3 times #269

Open XxMenotoxX opened 1 year ago

XxMenotoxX commented 1 year ago

here is the the error i get

FATAL EXCEPTION: main
E/AndroidRuntime(26642): Process: com.example.delivery_app, PID: 26642
E/AndroidRuntime(26642): java.lang.NullPointerException: Missing required view with ID: com.example.delivery_app:id/maneuverView
E/AndroidRuntime(26642):    at com.mapbox.navigation.dropin.databinding.MapboxManeuverGuidanceLayoutBinding.bind(MapboxManeuverGuidanceLayoutBinding.java:60)
E/AndroidRuntime(26642):    at com.mapbox.navigation.dropin.maneuver.ManeuverViewBinder.bind(ManeuverViewBinder.kt:27)
E/AndroidRuntime(26642):    at com.mapbox.navigation.dropin.maneuver.ManeuverViewBinder.bind(ManeuverViewBinder.kt:16)
E/AndroidRuntime(26642):    at com.mapbox.navigation.ui.base.lifecycle.UICoordinator$onAttached$1$invokeSuspend$$inlined$collect$1.emit(Collect.kt:136)
E/AndroidRuntime(26642):    at kotlinx.coroutines.flow.FlowKt__ZipKt$combine$$inlined$combineUnsafe$FlowKt__ZipKt$1$2.invokeSuspend(Zip.kt:333)
E/AndroidRuntime(26642):    at kotlinx.coroutines.flow.FlowKt__ZipKt$combine$$inlined$combineUnsafe$FlowKt__ZipKt$1$2.invoke(Unknown Source:13)
E/AndroidRuntime(26642):    at kotlinx.coroutines.flow.FlowKt__ZipKt$combine$$inlined$combineUnsafe$FlowKt__ZipKt$1$2.invoke(Unknown Source:6)
E/AndroidRuntime(26642):    at kotlinx.coroutines.flow.internal.CombineKt$combineInternal$2.invokeSuspend(Combine.kt:79)
E/AndroidRuntime(26642):    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
E/AndroidRuntime(26642):    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
E/AndroidRuntime(26642):    at android.os.Handler.handleCallback(Handler.java:938)
E/AndroidRuntime(26642):    at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(26642):    at android.os.Looper.loopOnce(Looper.java:211)
E/AndroidRuntime(26642):    at android.os.Looper.loop(Looper.java:300)
E/AndroidRuntime(26642):    at android.app.ActivityThread.main(ActivityThread.java:8322)
E/AndroidRuntime(26642):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(26642):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:556)
E/AndroidRuntime(26642):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1038)
E/AndroidRuntime(26642):    Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@8c69d01, Dispatchers.Main]
W/le.delivery_app(26642): type=1400 audit(0.0:24965): avc: denied { search } for name="mqsas" dev="sda11" ino=211 scontext=u:r:untrusted_app:s0:c223,c258,c512,c768 tcontext=u:object_r:mqsas_data_file:s0 tclass=dir permissive=0 app=com.example.delivery_app
W/OOMEventManagerFK(26642): Failed to mkdir /data/mqsas/hprof/
W/System  (26642): A resource failed to call close.
W/le.delivery_app(26642): type=1400 audit(0.0:24966): avc: denied { search } for name="mqsas" dev="sda11" ino=211 scontext=u:r:untrusted_app:s0:c223,c258,c512,c768 tcontext=u:object_r:mqsas_data_file:s0 tclass=dir permissive=0 app=com.example.delivery_app
W/le.delivery_app(26642): type=1400 audit(0.0:24967): avc: denied { search } for name="mqsas" dev="sda11" ino=211 scontext=u:r:untrusted_app:s0:c223,c258,c512,c768 tcontext=u:object_r:mqsas_data_file:s0 tclass=dir permissive=0 app=com.example.delivery_app
W/le.delivery_app(26642): type=1400 audit(0.0:24968): avc: denied { search } for name="mqsas" dev="sda11" ino=211 scontext=u:r:untrusted_app:s0:c223,c258,c512,c768 tcontext=u:object_r:mqsas_data_file:s0 tclass=dir permissive=0 app=com.example.delivery_app
W/le.delivery_app(26642): type=1400 audit(0.0:24969): avc: denied { getattr } for path="/data/mqsas" dev="sda11" ino=211 scontext=u:r:untrusted_app:s0:c223,c258,c512,c768 tcontext=u:object_r:mqsas_data_file:s0 tclass=dir permissive=0 app=com.example.delivery_app
W/le.delivery_app(26642): type=1400 audit(0.0:24970): avc: denied { search } for name="mqsas" dev="sda11" ino=211 scontext=u:r:untrusted_app:s0:c223,c258,c512,c768 tcontext=u:object_r:mqsas_data_file:s0 tclass=dir permissive=0 app=com.example.delivery_app
I/Process (26642): Sending signal. PID: 26642 SIG: 9
Lost connection to device.
eopeter commented 1 year ago

Is this an embedded Nav view? Does the view Id and app Id match your app?

XxMenotoxX commented 1 year ago

i dont know what is view Id and app Id

wbilalz400 commented 1 year ago

having similar issue yes this is an embedded nav view. The app id does matches the one with our id. no idea what is view id

TicketMarketTecnologia commented 1 year ago

I don't know if you're using lib "Location" but it's crashing.

XxMenotoxX commented 1 year ago

I do actually use location lib as an alternative way to track user location

TicketMarketTecnologia commented 1 year ago

Try https://pub.dev/packages/geolocator and replace the location lib

XxMenotoxX commented 1 year ago

I use both geo locator and locatin

nnadir35 commented 1 year ago

+1

nnadir35 commented 1 year ago

but I also get this error only when using google_map. maybe the google_map package is causing this issue

XxMenotoxX commented 1 year ago

One of the approaches that i tried to make is to delete the mapbox navigation lib and see if the google map lib is the cause of the problem everything went alright and i didn't encounter any issues related

wbilalz400 commented 1 year ago

@XxMenotoxX Did you remove the google map library and mapbox is working perfectly?

XxMenotoxX commented 1 year ago

Yes i did but i will try again on an empty project to see if i encounter the same issue

wbilalz400 commented 1 year ago

@XxMenotoxX I am trying to remove google map library as well to check

wbilalz400 commented 1 year ago

Same issue even when google maps are removed. It's a weird issue since it always happens at the 3rd time.

XxMenotoxX commented 1 year ago

same issue too , weird issue indeed @wbilalz400

alexeileyvamora commented 1 year ago

The same thing happens to me in embedded view and always at the third time call. Also when I define mapStyleUrlNight: "mapbox://styles/mapbox/traffic-night-v2" and mapStyleUrlDay: "mapbox://styles/mapbox/traffic-day-v2" the specified style does not change. Android.

AhmadMajd9 commented 1 year ago

any updates? the same error

mckeny3 commented 11 months ago

Did any one find the fix?

ARA-ZET commented 11 months ago

still looking for a solution and i have a production app for a client any alternatives

eopeter commented 11 months ago

I can take a look at it tonight. Can you list the exact steps to replicate?

rkreager commented 11 months ago

@eopeter here are my steps to replicate on Android, either simulator or device:

  1. Load my navigation page / widget.
  2. Build route and start navigation.
  3. Stop navigation.
  4. Unload Widget that includes map / navigate back to previous page.
  5. Repeat steps 1-4 a few more times and the crash will occur.

Here is the crash report:

E/AndroidRuntime(28909): FATAL EXCEPTION: main
E/AndroidRuntime(28909): Process: com.saferoutz.driver, PID: 28909
E/AndroidRuntime(28909): java.lang.NullPointerException: Missing required view with ID: com.saferoutz.driver:id/maneuverView
E/AndroidRuntime(28909):    at com.mapbox.navigation.dropin.databinding.MapboxManeuverGuidanceLayoutBinding.bind(MapboxManeuverGuidanceLayoutBinding.java:60)
E/AndroidRuntime(28909):    at com.mapbox.navigation.dropin.maneuver.ManeuverViewBinder.bind(ManeuverViewBinder.kt:27)
E/AndroidRuntime(28909):    at com.mapbox.navigation.dropin.maneuver.ManeuverViewBinder.bind(ManeuverViewBinder.kt:16)
E/AndroidRuntime(28909):    at com.mapbox.navigation.ui.base.lifecycle.UICoordinator$onAttached$1$invokeSuspend$$inlined$collect$1.emit(Collect.kt:136)
E/AndroidRuntime(28909):    at kotlinx.coroutines.flow.FlowKt__ZipKt$combine$$inlined$combineUnsafe$FlowKt__ZipKt$1$2.invokeSuspend(Zip.kt:333)
E/AndroidRuntime(28909):    at kotlinx.coroutines.flow.FlowKt__ZipKt$combine$$inlined$combineUnsafe$FlowKt__ZipKt$1$2.invoke(Unknown Source:13)
E/AndroidRuntime(28909):    at kotlinx.coroutines.flow.FlowKt__ZipKt$combine$$inlined$combineUnsafe$FlowKt__ZipKt$1$2.invoke(Unknown Source:6)
E/AndroidRuntime(28909):    at kotlinx.coroutines.flow.internal.CombineKt$combineInternal$2.invokeSuspend(Combine.kt:79)
E/AndroidRuntime(28909):    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
E/AndroidRuntime(28909):    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
E/AndroidRuntime(28909):    at android.os.Handler.handleCallback(Handler.java:938)
E/AndroidRuntime(28909):    at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(28909):    at android.os.Looper.loopOnce(Looper.java:226)
E/AndroidRuntime(28909):    at android.os.Looper.loop(Looper.java:313)
E/AndroidRuntime(28909):    at android.app.ActivityThread.main(ActivityThread.java:8751)
E/AndroidRuntime(28909):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(28909):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
E/AndroidRuntime(28909):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)
E/AndroidRuntime(28909):    Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@41982b8, Dispatchers.Main]

Happy to provide more details if needed.

ARA-ZET commented 11 months ago

its basically the same step to me as well, after repeating 3 times the app close

eopeter commented 11 months ago

I am not able to replicate this with the example app: https://youtu.be/-q8gwWmGdRM

mckeny3 commented 11 months ago

Thanks for looking into this...So it's in the embedded mode....so i would assign the driver coords as the first way point then the origin of the rider as the second way point....driver then navigate to the rider successfully....driver then swipe arrived ,then swipe to head to the rider destination..in this step I make sure to clear the route first ...then assign the driver location as the first way point then the rider coords as the second waypoint...then route get draw...then as driver hit navigate button...it crashes....if you reopen the app and assign the same way points from state it doesn't crash ....so that's tell you nothing is wrong with the route.

XxMenotoxX commented 9 months ago

hi @eopeter did you find any solution for the problem sir

maicojay16 commented 9 months ago

I also got the same problem when using the navigation.

Mine works well in the first run, But after that when i try to navigate again the app crash.

  1. Load the navigation screen and navigate.
  2. Cancel the navigation/ Finish the navigation.
  3. Go back to search screen and navigate again.
  4. The app crash

Here is the crash report:

image

maicojay16 commented 9 months ago

Hello @eopeter is there any solutions or updates sir? Thank you.

eopeter commented 9 months ago

is this issue still happening with the current version 0.2.0?

rkreager commented 9 months ago

@eopeter I will try it with version 0.2.0 and report back.

maicojay16 commented 9 months ago

@eopeter i will try the new version 0.2.0 and will give a feedback thanks for the response.

fabiolin commented 9 months ago

I am having the same issue, in version 0.2.2, using location package

eopeter commented 9 months ago

Can you copy and paste your stack trace?

eopeter commented 9 months ago

Your token is in this stack trace. Please cycle your MapBox access token for security reasons.

fabiolin commented 9 months ago

ok, i have changed the token, thanks

eopeter commented 8 months ago

Will do and get back to you

ddiegosousa commented 8 months ago

@eopeter In your example, replace the main.dart code with the code below:

import 'package:flutter/material.dart';

import 'app.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( home: Builder( builder: (context) => Center( child: Center( child: ElevatedButton( child: const Text("Click"), onPressed: () { Navigator.push( context, MaterialPageRoute( builder: (context) => const SampleNavigationApp()), ); }), ), ))); } }


  1. Open the example app and click on the "CLICK" button (main.dart modified with code above)
  2. Click/tap Build route and start navigation.
  3. Tap Stop navigation.
  4. Go back to the previous page with the ANDROID BACK button
ddiegosousa commented 8 months ago

Below is the simulation video, where in the 3rd navigation it dates the system and generates the error reported in this problem Meu Vídeo1.zip

eopeter commented 8 months ago

Can you upload the video to YouTube?

ddiegosousa commented 8 months ago

https://www.youtube.com/shorts/Y7o1IO42QnU

ddiegosousa commented 8 months ago

@eopeter were you able to simulate it in your environment? Debugging here, I noticed that even when closing the router (screen) that has the map with Navigation.pop, some threads (taks, microtaks) are still running. I was also unable to identify the problem in the viewbinding of your package.

SPiercer commented 8 months ago

@eopeter gentle reminder on this as it's affecting lot's of people

-- @XxMenotoxX please add some labels on it

eopeter commented 8 months ago

@SPiercer I will take a look at this when I have some free time. If you have capacity, please feel free to take a look and send a PR

marciotisouza commented 7 months ago

Hello everybody !

The problem of failing after 3 navigations persists, has anyone managed to get around this problem?

marciotisouza commented 7 months ago

I put the section below in dispose() and nothing stopped the route process:

@override void dispose() { _controller?.dispose(); super.dispose(); }

I also tried to stop when I was close to reaching the end of the route:

if (currentLegDistanceRemaining < 10.0 ) { _controller?.clearRoute(); await _controller?.finishNavigation(); }

If you leave it, it continues launching the method: MapBoxEvent.progress_change

marciotisouza commented 7 months ago

I tested with version 0.2.0 but the problem is the same, after finishing the route it keeps working and sending information, even leaving the screen it was on and returning to the app's main screen it continues transmitting information. See below that it has finished the route section and continues arriving in the MapBoxEvent.progress_change method

currentLegDistanceRemaining: 0.0 W/Mapbox (30124): [nav-native]: Using the same old location with timestamp = 858841291852758ns, lng = -46.502187, lat = -23.430765 for 10 seconds E/Mapbox (30124): [nav-sdk]: [MapboxFollowingFrameProcessor] Start position is beyond line

When you return to the main screen of the app, it sends the message below, one after the other:

E/Mapbox (30124): [nav-sdk]: [MapboxFollowingFrameProcessor] Start position is beyond line I/stem.br_expres(30124): Explicit concurrent copying GC freed 5579(287KB) AllocSpace objects, 0(0B) LOS objects, 49% free, 8693KB/16MB, paused 303us total 89.885ms two E/Mapbox (30124): [nav-sdk]: [MapboxFollowingFrameProcessor] Start position is beyond line W/Mapbox (30124): [nav-native]: Using the same old location with timestamp = 858841291852758ns, lng = -46.502187, lat = -23.430765 for 80 seconds E/Mapbox (30124): [nav-sdk]: [MapboxFollowingFrameProcessor] Start position is beyond line I/stem.br_expres(30124): Explicit concurrent copying GC freed 5582(304KB) AllocSpace objects, 0(0B) LOS objects, 49% free, 8741KB/17MB, paused 584us total 106.255ms two E/Mapbox (30124): [nav-sdk]: [MapboxFollowingFrameProcessor] Start position is beyond line I/stem.br_expres(30124): Explicit concurrent copying GC freed 6239(335KB) AllocSpace objects, 0(0B) LOS objects, 49% free, 8709KB/17MB, paused 146us total 61,031ms

marciotisouza commented 7 months ago

I noticed two situations and would like to see if this is what is causing the anomaly in the package.

On the third attempt to use the route the application minimizes and does not close, when I click on it it returns and I can use it twice more until it minimizes again.

The second situation refers to the finishNavigation method which is returning FALSE, is this correct?

marciotisouza commented 7 months ago

@eopeter The package is perfect, I tested everything and it works very well, we still need to resolve this issue of closing after 3 routes executed, we will need your help, I know you are busy but if you can help us all, we would be grateful. I haven't found another package with such perfection, I need to put it into production in my project.

If you need an example again, I'll post it for you, but they've previously indicated how to get to the problem.

marciotisouza commented 7 months ago

@eopeter I asked on a flutter forum and someone answered this, maybe this is the way to fix the problem: You can get around this by "resetting" the package every time you start the race. I'm almost sure that the problem is manipulation during the enumeration of a list in Java, in Java this common practice causes a lot of errors, you have to clone the list to enumerate.

codenomaddev commented 7 months ago

@marciotisouza @ddiegosousa I'm Brazilian and I'm having some problems in production with this lib and I'd like to talk on a call with you guys... to see if we can help each other. (Vamos fazer uma call?)

marciotisouza commented 7 months ago

Yes, you can call me on gmail chat