Milad-Akarie / auto_route_library

Flutter route generator
MIT License
1.56k stars 394 forks source link

Bad state: Future already completed #1005

Open koral-- opened 2 years ago

koral-- commented 2 years ago

This is an anonymous automated crash report.

StateError: Bad state: Future already completed
  File "future_impl.dart", line 44, in _AsyncCompleter.complete
  File "navigator.dart", line 360, in Route.didComplete
  File "navigator.dart", line 338, in Route.didPop
  File "routes.dart", line 71, in OverlayRoute.didPop
  File "routes.dart", line 262, in TransitionRoute.didPop
  File "routes.dart", line 669, in LocalHistoryRoute.didPop
  File "auto_route_navigator.dart", line 73, in _AutoRouteNavigatorState.build.<fn>
  File "navigator.dart", line 4892, in NavigatorState.pop
  File "navigator.dart", line 4933, in NavigatorState.popUntil
  File "routing_controller.dart", line 921, in StackRouter.popUntil
  File "routing_controller.dart", line 1170, in StackRouter.popUntilRouteWithName

Affected line in my code: AutoRouter.of(context).popUntilRouteWithName(<SomePage>Route.name); It is the loader (modal dialog) hiding, invoked from the cubit listener. However, emissions won't occur if the cubit is closed. I've tried inserting the artificial delays to simulate some race conditions eg. pop the page from which context is taken just before calling popUntilRouteWithName but I could not reproduce any exception so I guess there is a bug in this library.

auto_route: 3.2.4 flutter 2.8.3 Android 12

Milad-Akarie commented 2 years ago

@koral-- Not sure what's going on here, popUntilRouteWithName is just a helper function that calls popUntil on the native NavigatorState so there isn't much code on my side. any idea how this can be reproduced?

koral-- commented 2 years ago

any idea how this can be reproduced?

No. I described what I've tried:

I've tried inserting the artificial delays to simulate some race conditions eg. pop the page from which context is taken just before calling popUntilRouteWithName but I could not reproduce any exception so I guess there is a bug in this library.

However, I was not able to reproduce that.

vimaxwell commented 2 years ago
Future already completed. Error thrown null.
       at _AsyncCompleter.complete(_AsyncCompleter.java)
       at Route.didComplete(navigator.dart:360)
       at Route.didPop(navigator.dart:338)
       at OverlayRoute.didPop(routes.dart:72)
       at TransitionRoute.didPop(routes.dart:263)
       at LocalHistoryRoute.didPop(routes.dart:670)
       at _AutoRouteNavigatorState.build.<fn>(auto_route_navigator.dart:73)
       at NavigatorState.pop(navigator.dart:4900)
       at NavigatorState.popUntil(navigator.dart:4941)
       at StackRouter.popUntil(routing_controller.dart:921)
       at StackRouter.pushAndPopUntil(routing_controller.dart:1123)

In my firebase, there are errors like this

Constans commented 2 years ago

@Milad-Akarie , I got these kind of errors when using structures like:

try {
  // some code that might fail
  myFunc().then(processValue).catchError(handleError);
  // some other code that might fail
} catch(e) {
  // do something on error
}

Combining structures like try...catch and ().then...catchError together might be the culprit for these errors. I solved it on my side by sticking to the try...catch only.

olegys commented 1 year ago

@Milad-Akarie I have the same thing happen when quickly switching child tabs in the bottom navigation

`I/flutter (21852): ----------------FIREBASE CRASHLYTICS---------------- I/flutter (21852): 'package:flutter/src/widgets/navigator.dart': Failed assertion: line 2849 pos 18: '!navigator._debugLocked': is not true. I/flutter (21852): #0 _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:51:61) I/flutter (21852): #1 _AssertionError._throwNew (dart:core-patch/errors_patch.dart:40:5) I/flutter (21852): #2 _RouteEntry.handlePush. (package:flutter/src/widgets/navigator.dart:2849:18) I/flutter (21852): #3 TickerFuture.whenCompleteOrCancel.thunk (package:flutter/src/scheduler/ticker.dart:420:15) I/flutter (21852): #4 _rootRunUnary (dart:async/zone.dart:1399:47) I/flutter (21852): #5 _CustomZone.runUnary (dart:async/zone.dart:1300:19) I/flutter (21852): #6 _FutureListener.handleError (dart:async/future_impl.dart:165:22) I/flutter (21852): #7 Future._propagateToListeners.handleError (dart:async/future_impl.dart:778:47) I/flutter (21852): #8 Future._propagateToListeners (dart:async/future_impl.dart:799:13) I/flutter (21852): #9 Future._completeError (dart:async/future_impl.dart:574:5) I/flutter (21852): #10 Future._asyncCompleteError. (dart:async/future_impl.dart:665:7) I/flutter (21852): #11 _rootRun (dart:async/zone.dart:1391:13) I/flutter (21852): #12 _CustomZone.run (dart:async/zone.dart:1293:19) I/flutter (21852): #13 _CustomZone.runGuarded (dart:async/zone.dart:1201:7) I/flutter (21852): ----------------------------------------------------

======== Exception caught by gesture =============================================================== The following StateError was thrown while handling a gesture: Bad state: Future already completed

When the exception was thrown, this was the stack:

1 Route.didComplete (package:flutter/src/widgets/navigator.dart:360:19)

2 Route.didPop (package:flutter/src/widgets/navigator.dart:338:5)

3 OverlayRoute.didPop (package:flutter/src/widgets/routes.dart:72:36)

4 TransitionRoute.didPop (package:flutter/src/widgets/routes.dart:267:18)

5 LocalHistoryRoute.didPop (package:flutter/src/widgets/routes.dart:700:18)

6 _AutoRouteNavigatorState.build. (package:auto_route/src/router/widgets/auto_route_navigator.dart:74:26)

7 NavigatorState.pop (package:flutter/src/widgets/navigator.dart:4957:28)

8 NavigatorState.popUntil (package:flutter/src/widgets/navigator.dart:5000:7)

9 StackRouter.popUntilRoot (package:auto_route/src/router/controller/routing_controller.dart:999:33)

10 _MainPageState._onSetActiveIndex (package:df_platform/pages/main_page/main_page.dart:35:45)

11 _MainPageState.build.. (package:df_platform/pages/main_page/main_page.dart:71:13)

12 NavigationBar._handleTap. (package:flutter/src/material/navigation_bar.dart:150:37)

13 _InkResponseState.handleTap (package:flutter/src/material/ink_well.dart:1072:21)

14 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:253:24)

15 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:627:11)

16 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:306:5)

17 BaseTapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:276:7)

18 GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:163:27)

19 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:464:20)

20 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:440:22)

21 RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:337:11)

22 GestureBinding._handlePointerEventImmediately (package:flutter/src/gestures/binding.dart:395:7)

23 GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:357:5)

24 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:314:7)

25 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:295:7)

29 _invoke1 (dart:ui/hooks.dart:169:10)

30 PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:341:7)

31 _dispatchPointerDataPacket (dart:ui/hooks.dart:94:31)

(elided 4 frames from dart:async) Handler: "onTap" Recognizer: TapGestureRecognizer#e7400 debugOwner: GestureDetector state: ready won arena finalPosition: Offset(201.8, 813.1) finalLocalPosition: Offset(70.9, 42.2) button: 1 sent tap down`

github-actions[bot] commented 1 year ago

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

koral-- commented 1 year ago

This issue should not be closed automatically. There is neither a solution nor explicit statement that it is not a bug in this library (or it is not feasible to fix this).

Milad-Akarie commented 1 year ago

@koral-- as stated before it's not clear how to reproduce this bug, do you have any updates regarding this?

koral-- commented 1 year ago

I have more occurrences logged from anonymous crash reports (along with breadcrumbs containing the navigation history) and they seems to be similar to @olegys written above. Eg. there are 3 pops and 1 push in the same second and finally the following exception:

StateError: Bad state: Future already completed
  File "future_impl.dart", line 35, in _AsyncCompleter.complete
  File "navigator.dart", line 360, in Route.didComplete
  File "navigator.dart", line 338, in Route.didPop
  File "routes.dart", line 72, in OverlayRoute.didPop
  File "routes.dart", line 267, in TransitionRoute.didPop
  File "routes.dart", line 700, in LocalHistoryRoute.didPop
  File "auto_route_navigator.dart", line 74, in _AutoRouteNavigatorState.build.<fn>
  File "navigator.dart", line 4957, in NavigatorState.pop
  File "navigator.dart", line 5000, in NavigatorState.popUntil
  File "routing_controller.dart", line 1016, in StackRouter.popUntil
  File "routing_controller.dart", line 1226, in StackRouter.pushAndPopUntil

So it looks like some race condition. E.g. Some async function(s) may be executed in parallel instead of sequentially.

redarflap commented 1 year ago

I probably got the same problem. In my situation it happens, when the app is launched by a password recovery link. Then pushAndPopUntil is called twice in quick succession.

This scenario throws an exception:

   appRouter.pushAndPopUntil(const AuthRouter(children: [SignInRoute()]), predicate: (route) => false);

   Event gets fetched instantly by a listener in SignInPage

   appRouter.pushAndPopUntil(const AuthRouter(children: [VerifyRoute()]), predicate: (route) => false);

When adding a delay of 1000ms before listening for the event, everything works fine. Just waiting 100-200ms is not enough strangely.

Stack Trace in release

StateError: Bad state: Future already completed
  File "future_impl.dart", line 35, in _AsyncCompleter.complete
  File "navigator.dart", line 360, in Route.didComplete
  File "navigator.dart", line 338, in Route.didPop
  File "routes.dart", line 72, in OverlayRoute.didPop
  File "routes.dart", line 267, in TransitionRoute.didPop
  File "routes.dart", line 700, in LocalHistoryRoute.didPop
  File "auto_route_navigator.dart", line 74, in AutoRouteNavigatorState.build.<fn>
  File "navigator.dart", line 4957, in NavigatorState.pop
  File "navigator.dart", line 5000, in NavigatorState.popUntil
  File "routing_controller.dart", line 1016, in StackRouter.popUntil
  File "routing_controller.dart", line 1226, in StackRouter.pushAndPopUntil
  File "app_widget.dart", line 98, in AppWidget.build.<fn>.<fn>
  File "auth_service.freezed.dart", line 714, in _$_Recovery.maybeWhen
  File "app_widget.dart", line 78, in AppWidget.build.<fn>
  File "zone.dart", line 1598, in _RootZone.runBinaryGuarded
  File "element.dart", line 532, in ProviderElementBase._notifyListeners.<fn>
  File "member_failure.freezed.dart", line 149, in _$_NoConnection.map
  File "element.dart", line 529, in ProviderElementBase._notifyListeners
  File "element.dart", line 150, in ProviderElementBase.setState
  File "notifier.dart", line 41, in NotifierBase.state=

Stack trace in debug

_AssertionError: 'package:flutter/src/widgets/navigator.dart': Failed assertion: line 3508 pos 12: '!_debugLocked': is not true.
  File "errors_patch.dart", line 51, col 61, in _AssertionError._doThrowNew
  File "errors_patch.dart", line 40, col 5, in _AssertionError._throwNew
  File "navigator.dart", line 3508, col 12, in NavigatorState.dispose
  File "framework.dart", line 5105, col 11, in StatefulElement.unmount
  File "framework.dart", line 1917, col 13, in _InactiveElements._unmount
  File "iterable.dart", line 39, col 13, in ListIterable.forEach
  File "framework.dart", line 1926, col 25, in _InactiveElements._unmountAll
  File "framework.dart", line 2523, col 15, in BuildOwner.lockState
  File "framework.dart", line 2947, col 7, in BuildOwner.finalizeTree
  File "binding.dart", line 885, col 19, in WidgetsBinding.drawFrame
  File "binding.dart", line 378, col 5, in RendererBinding._handlePersistentFrameCallback
  File "binding.dart", line 1175, col 15, in SchedulerBinding._invokeFrameCallback
  File "binding.dart", line 1104, col 9, in SchedulerBinding.handleDrawFrame
  File "binding.dart", line 1015, col 5, in SchedulerBinding._handleDrawFrame
  File "hooks.dart", line 148, col 13, in _invoke
  File "platform_dispatcher.dart", line 318, col 5, in PlatformDispatcher._drawFrame
  File "hooks.dart", line 115, col 31, in _drawFrame

auto_route: 5.0.2 auto_route_generator: 5.0.3 flutter 3.3.6 Android 12

github-actions[bot] commented 1 year ago

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

koral-- commented 1 year ago

This issue should be exempted from autoclosing until there is some change.

medyas commented 1 year ago

Getting the same issue when using pushAndPopUntil inside a BlocListener to logout the user:

context.router.pushAndPopUntil( const OnBoardingRoute(), predicate: (_) => false, );

Using:

  auto_route: ^6.4.0
  auto_route_generator: ^6.2.0
  build_runner: ^2.3.3

PS: this was also happening in V5.0.4, So i migrated to V6.4.0 but the issue kept happening.

Flutter Doctor:

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.7.12, on Microsoft Windows [Version 10.0.22621.1555], locale en-AS)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
[√] Chrome - develop for the web
[X] Visual Studio - develop for Windows
    X Visual Studio not installed; this is necessary for Windows development.
      Download at https://visualstudio.microsoft.com/downloads/.
      Please install the "Desktop development with C++" workload, including all of its default components
[√] Android Studio (version 2022.1)
[√] IntelliJ IDEA Ultimate Edition (version 2022.3)
[√] Connected device (4 available)
[√] HTTP Host Availability
#0

_ AsyncCompleter.complete (dart:async/

future_impl.dart:35)

#1

Route.didComplete (package:flutter/src/widgets/

navigator.dart:362)

_RouteEntry.handleComplete (package:flutter/src/

#2

widgets/navigator.dart:2963)

#3

NavigatorState.flushHistoryUpdates

(package:flutter/src/widgets/navigator.dart:3980)

#4

NavigatorState._updatePages (package:flutter/src/

widgets/navigator.dart:5879)

Navigator State.didUpdateWidget (package:flutter/

#5

srC/widgets/navigator.dart:3530)

StatefulElement.update (package:flutter/src/

#6

widgets/framework.dart:5142)

#7

Element.updateChild (package:flutter/src/ widgets/

framework.dart:3660)

#8£ ComponentElement.performRebuild

(package:flutter/src/widgets/framework.dart:4993)

StatefulElement.performRebuild (package:flutter/

#9

src/ widgets/framework.dart:5133)

#10 E ement.rebuild (package:flutter/src/widgets/

framework.dart:4690)

#11 StatefulElement.update (package:flutter/src/

widgets/framework.dart:5156)

#12

Element.updateChild (package:flutter/src/widgets/

framework.dart:3660)

#13 ComponentElement.performRebuild

(package:flutter/src/widgets/framework.dart:4993)

#14 Element.rebuild (package:flutter/src/ widgets/

framework.dart:4690)

roxyElement.update (package:flutter/src/widgets/

#15

framework.dart:5301)

#16

Element.updateChild (package:flutter/src/widgets/

framework.dart:3660)

#17 ComponentElement.performRebuild

(package:flutter/src/widgets/framework.dart:4993)

#18

Element.rebuild (package:flutter/src/widgets/

framework.dart:4690)

ProxyElement.update (package:flutter/src/widgets/

#19

framework.dart:5301)

#20 Element.updateChild (package:flutter/src/

ProxyElement.update (package:flutter/src/widgets/

#19

framework.dart:5301)

#20 Element.updateChild (package:flutter/src/ widgets/

framework.dart:3660)

#21 ComponentElement.performRebuild

(package:flutter/src/widgets/framework.dart:4993)

#22 StatefulElement.performRebuild (package:flutter/

src/widgets/framework.dart:5133)

#23

Element.rebuild (package:flutter/src/ widgets/

framework.dart:4690)

#24 StatefulElement.update (package:flutter/src/

widgets/framework.dart:5156)

#25 Element.updateChild (package:flutter/src/widgets/

framework.dart:3660)

#26 ComponentElement.performRebuild

(package:flutter/src/widgets/framework.dart:4993)

#27 Element.rebuild (package:flutter/src/widgets/

framework.dart:4690)

#28 StatelessElement.update (package:flutter/ src/

widgets/framework.dart:5044)

Element.updateChild (package:flutter/src/widgets/

#29

framework.dart:3660)

ComponentElement.performRebuild

#30

(package:flutter/src/widgets/framework.dart:4993)

#31 Element.rebuild (package:flutter/src/widgets/

framework.dart:4690)

#32 ProxyElement.update (package:flutter/src/widgets/

framework.dart:5301)

Element.updateChild (package:flutter/src/widgets/

#33

framework.dart:3660)

#34

ComponentElement.performRebuild

(package:flutter/src/widgets/framework.dart:4993)

#35

Element.rebuild (package:flutter/src/widgets/

framework.dart:4690)

ProxyElement.update (package:flutter/src/widgets/

#36

framework.dart:5301)

#37

Element.updateChild (package:flutter/src/widgets/

framework.dart:3660)

#38 ComponentElement.performRebuild

(package:flutter/src/widgets/framework.dart:4993)

StatefulElement.performRebuild (package:flutter/

#39

src/widgets/framework.dart:5133)

#40 Element.rebuild (package:flutter/src/ widgets/

framework.dart:4690)

#41

BuildOwner.buildScope (package:flutter/src/

widgets/framework.dart:2743)

#42£ WidgetsBinding.drawFrame (package:flutter/src/

widgets/binding.dart:863)

RendererBinding._handlePersistentFrameCalback

#43

(package:flutter/src/rendering/binding.dart:381)

#44 SchedulerBinding._invokeFrameCallback

(package:flutter/src/scheduler/binding.dart:1289)

#45 SchedulerBinding.handleDrawFrame

(package:flutter/src/scheduler/binding.dart:1218)

#46 Scheduler Binding._handleDrawFrame

(package:flutter/src/scheduler/binding.dart:1076)

#47 _invoke (dart:ui/hooks.dart:145)

#48 PlatformDispatcher._drawFrame (dart:ui/

platform_dispatcher.dart:338)

#49 _drawFrame (dart:ui/hooks.dart:112)
github-actions[bot] commented 1 year ago

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

koral-- commented 1 year ago

https://github.com/Milad-Akarie/auto_route_library/issues/1005#issuecomment-1457865849

dmrickey commented 1 year ago

I don't have repro steps, but it would be super nice if this could be resolved. In my case it's happening when our offline detection kicks in and sees if it needs to navigate the user away from a page that requires an active connection. I just haven't been able to figure out exactly which part is causing it.

tusharanchliyajain commented 1 year ago

Any update on this issue ?

mrqaidi commented 1 year ago

same issue is this fixed ?

appRouter.pushAndPopUntil(DashboardRoute(), predicate: (_) => false);

github-actions[bot] commented 11 months ago

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

koral-- commented 11 months ago

https://github.com/Milad-Akarie/auto_route_library/issues/1005#issuecomment-1457865849

github-actions[bot] commented 10 months ago

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

koral-- commented 10 months ago

This issue should be exempted from autoclosing until there is some change

babirms commented 9 months ago

Also having this problem, I'm trying to use pushAndPopUntil and this happens:

I/flutter (17920): Bad state: Future already completed
I/flutter (17920): #0      _AsyncCompleter.complete (dart:async/future_impl.dart:41:31)
I/flutter (17920): #1      Route.didComplete (package:flutter/src/widgets/navigator.dart:362:19)
I/flutter (17920): #2      Route.didPop (package:flutter/src/widgets/navigator.dart:340:5)
I/flutter (17920): #3      OverlayRoute.didPop (package:flutter/src/widgets/routes.dart:77:36)
I/flutter (17920): #4      TransitionRoute.didPop (package:flutter/src/widgets/routes.dart:306:18)
I/flutter (17920): #5      LocalHistoryRoute.didPop (package:flutter/src/widgets/routes.dart:745:18)
I/flutter (17920): #6      AutoRouteNavigatorState.build.<anonymous closure> (package:auto_route/src/router/widgets/auto_route_navigator.dart:99:26)
I/flutter (17920): #7      NavigatorState.pop (package:flutter/src/widgets/navigator.dart:5045:28)
I/flutter (17920): #8      NavigatorState.popUntil (package:flutter/src/widgets/navigator.dart:5085:7)
I/flutter (17920): #9      StackRouter.popUntil (package:auto_route/src/router/controller/routing_controller.dart:1404:42)
I/flutter (17920): #10     StackRouter.pushAndPopUntil (package:auto_route/src/router/controller/routing_controller.dart:1680:13)

It's not everytime I tap the button (that calls the function), but happens a lot and those are the only logs on console.

artebiakin commented 8 months ago

Hey folks, I created a repository where you can reproduce this error. https://github.com/artebiakin/auto_route_demo In my case, this happens when the request, for example after caching, is executed quickly. Therefore, the problem was floating in my case. How reproduce:

  1. Run the app
  2. Click to the "Redirect" button

I change my popAndPushAll in:

  void _redirectWithFix() => context.router
    ..removeLast()
    ..pushAll(const [
      FirstRoute(),
      SecondRoute(),
    ]);

This helps solve the problem.

melWiss commented 8 months ago

Hello, we're facing the same problem in our project when we call "popUntilRouteWithName" method. it sometimes happens, not very frequent but it would be nice to have a fix soon.

vivekkartha7 commented 7 months ago

@Milad-Akarie Were you able to look into this? We are currently using a workaround that introduces a fixed delay of 500ms before subsequent navigations. But that work around does cause obvious delays. Would appreciate if this can be either recognised as a defect or a solution is put forth

SdxCoder commented 7 months ago

@Milad-Akarie It needs your attention

We have our app in production and we are facing this issue repeatedly. As you can see in the code below, we are not calling multiple push and pops in succession where we can delay subsequent navigation calls by some ms. Rather we are simply calling appRouter.popUntilRoot();. Crash comes from the last line here.

Code Example

  Future<void> loginAsGuest() async {
    if (state.valueOrNull?.isGuestUser ?? false) {
      unawaited(appRouter.pop());
    } else {
      final authRepository = ref.read(repositoryProvider).authReposiory;
      final appSettingsRepository =
          ref.read(repositoryProvider).appSettingsRepository;
      await authRepository.handshake();
      appSettingsRepository.saveFirstTimeAppOpen();
      state = AsyncValue.data(User.guest());
      appRouter.popUntilRoot();
    }
  }

Crash Log

# Crashlytics - Stack trace
# Platform: apple
# Version: 1.29.0 (29)
# Issue: 00a82426760396cd8398d17108e0527a
# Session: ef9c6261c21b4d98a324c18125507ee5_DNE_0_v2
# Date: Fri Jan 26 2024 12:00:30 GMT-0700 (Mountain Standard Time)

Fatal Exception: FlutterError
0  ???                            0x0 _AsyncCompleter.complete (dart:async)
1  ???                            0x0 Route.didComplete + 418 (navigator.dart:418)
2  ???                            0x0 Route.didPop + 396 (navigator.dart:396)
3  ???                            0x0 OverlayRoute.didPop + 77 (routes.dart:77)
4  ???                            0x0 TransitionRoute.didPop + 306 (routes.dart:306)
5  ???                            0x0 LocalHistoryRoute.didPop + 757 (routes.dart:757)
6  ???                            0x0 AutoRouteNavigatorState.build.<fn> + 74 (auto_route_navigator.dart:74)
7  ???                            0x0 NavigatorState.pop + 5245 (navigator.dart:5245)
8  ???                            0x0 NavigatorState.popUntil + 5285 (navigator.dart:5285)
9  ???                            0x0 StackRouter.popUntilRoot + 999 (routing_controller.dart:999)
10 ???                            0x0 GetSignedInUserNotifier.loginAsGuest + 53 (get_signed_in_user_provider.dart:53)

Crashed: com.apple.main-thread
0  FirebaseCrashlytics            0x214f4 FIRCLSProcessRecordAllThreads + 184
1  FirebaseCrashlytics            0x218d4 FIRCLSProcessRecordAllThreads + 1176
2  FirebaseCrashlytics            0x18a04 FIRCLSHandler + 48
3  FirebaseCrashlytics            0x12eb4 FIRCLSExceptionRecordOnDemand + 1328
4  FirebaseCrashlytics            0x128f4 FIRCLSExceptionRecordOnDemandModel + 228
5  FirebaseCrashlytics            0x20cc0 -[FIRCLSOnDemandModel recordOnDemandExceptionWithModel:] + 68
6  FirebaseCrashlytics            0x20720 -[FIRCLSOnDemandModel recordOnDemandExceptionIfQuota:withDataCollectionEnabled:usingExistingReportManager:] + 164
7  FirebaseCrashlytics            0x2eb34 -[FIRCrashlytics recordOnDemandExceptionModel:] + 140
8  Runner                         0x4f3ea0 -[FLTFirebaseCrashlyticsPlugin recordError:withMethodCallResult:] + 177 (FLTFirebaseCrashlyticsPlugin.m:177)
9  Runner                         0x4f375c -[FLTFirebaseCrashlyticsPlugin handleMethodCall:result:] + 101 (FLTFirebaseCrashlyticsPlugin.m:101)
10 Flutter                        0x5e1a38 InternalFlutterGpuTestClass_Method + 5940
11 Flutter                        0x43c00 (Missing UUID 4c4c44da55553144a1f7c3e66c77eeff)
12 libdispatch.dylib              0x26a8 _dispatch_call_block_and_release + 32
13 libdispatch.dylib              0x4300 _dispatch_client_callout + 20
14 libdispatch.dylib              0x12998 _dispatch_main_queue_drain + 984
15 libdispatch.dylib              0x125b0 _dispatch_main_queue_callback_4CF + 44
16 CoreFoundation                 0x3701c __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16
17 CoreFoundation                 0x33d28 __CFRunLoopRun + 1996
18 CoreFoundation                 0x33478 CFRunLoopRunSpecific + 608
19 GraphicsServices               0x34f8 GSEventRunModal + 164
20 UIKitCore                      0x22c62c -[UIApplication _run] + 888
21 UIKitCore                      0x22bc68 UIApplicationMain + 340
22 Runner                         0x99c8 main + 9 (AppDelegate.swift:9)
23 ???                            0x1b6102dcc (Missing)

Thread
0  libsystem_pthread.dylib        0x19fc start_wqthread + 438

com.apple.uikit.eventfetch-thread
0  libsystem_kernel.dylib         0x1178 mach_msg2_trap + 8
1  libsystem_kernel.dylib         0xf10 mach_msg2_internal + 80
2  libsystem_kernel.dylib         0xe28 mach_msg_overwrite + 436
3  libsystem_kernel.dylib         0xc68 mach_msg + 24
4  CoreFoundation                 0x35b1c __CFRunLoopServiceMachPort + 160
5  CoreFoundation                 0x33a14 __CFRunLoopRun + 1208
6  CoreFoundation                 0x33478 CFRunLoopRunSpecific + 608
7  Foundation                     0x2c48c -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 212
8  Foundation                     0x5974c -[NSRunLoop(NSRunLoop) runUntilDate:] + 64
9  UIKitCore                      0x18e4a8 -[UIEventFetcher threadMain] + 420
10 Foundation                     0xafde0 __NSThread__start__ + 732
11 libsystem_pthread.dylib        0x24d4 _pthread_start + 136
12 libsystem_pthread.dylib        0x1a10 thread_start + 8

io.flutter.1.ui
0  libsystem_kernel.dylib         0x1178 mach_msg2_trap + 8
1  libsystem_kernel.dylib         0xf10 mach_msg2_internal + 80
2  libsystem_kernel.dylib         0xe28 mach_msg_overwrite + 436
3  libsystem_kernel.dylib         0xc68 mach_msg + 24
4  CoreFoundation                 0x35b1c __CFRunLoopServiceMachPort + 160
5  CoreFoundation                 0x33a14 __CFRunLoopRun + 1208
6  CoreFoundation                 0x33478 CFRunLoopRunSpecific + 608
7  Flutter                        0x2e95e8 (Missing UUID 4c4c44da55553144a1f7c3e66c77eeff)
8  Flutter                        0x2e8c5c (Missing UUID 4c4c44da55553144a1f7c3e66c77eeff)
9  libsystem_pthread.dylib        0x24d4 _pthread_start + 136
10 libsystem_pthread.dylib        0x1a10 thread_start + 8

io.flutter.1.raster
0  libsystem_kernel.dylib         0x110c semaphore_timedwait_trap + 8
1  libdispatch.dylib              0x4918 _dispatch_sema4_timedwait + 64
2  libdispatch.dylib              0x4f14 _dispatch_semaphore_wait_slow + 76
3  QuartzCore                     0x110ea8 CAMetalLayerPrivateNextDrawableLocked(CAMetalLayer*, CAMetalDrawable**, unsigned long*) + 968
4  QuartzCore                     0x110a74 -[CAMetalLayer nextDrawable] + 128
5  Flutter                        0x5ea4e0 InternalFlutterGpuTestClass_Method + 41436
6  Flutter                        0x3ebc30 (Missing UUID 4c4c44da55553144a1f7c3e66c77eeff)
7  Flutter                        0x3ec2c4 (Missing UUID 4c4c44da55553144a1f7c3e66c77eeff)
8  Flutter                        0x2e7734 (Missing UUID 4c4c44da55553144a1f7c3e66c77eeff)
9  Flutter                        0x3eb958 (Missing UUID 4c4c44da55553144a1f7c3e66c77eeff)
10 Flutter                        0x3eccbc (Missing UUID 4c4c44da55553144a1f7c3e66c77eeff)
11 Flutter                        0x3ec4fc (Missing UUID 4c4c44da55553144a1f7c3e66c77eeff)
12 Flutter                        0x404838 (Missing UUID 4c4c44da55553144a1f7c3e66c77eeff)
13 Flutter                        0x2e5d68 (Missing UUID 4c4c44da55553144a1f7c3e66c77eeff)
14 Flutter                        0x2e94fc (Missing UUID 4c4c44da55553144a1f7c3e66c77eeff)
15 CoreFoundation                 0xad3ec __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 32
16 CoreFoundation                 0xad094 __CFRunLoopDoTimer + 1004
17 CoreFoundation                 0x36c84 __CFRunLoopDoTimers + 288
18 CoreFoundation                 0x33c9c __CFRunLoopRun + 1856
19 CoreFoundation                 0x33478 CFRunLoopRunSpecific + 608
20 Flutter                        0x2e95e8 (Missing UUID 4c4c44da55553144a1f7c3e66c77eeff)
21 Flutter                        0x2e8c5c (Missing UUID 4c4c44da55553144a1f7c3e66c77eeff)
22 libsystem_pthread.dylib        0x24d4 _pthread_start + 136
23 libsystem_pthread.dylib        0x1a10 thread_start + 8

io.flutter.1.io
0  libsystem_kernel.dylib         0x1178 mach_msg2_trap + 8
1  libsystem_kernel.dylib         0xf10 mach_msg2_internal + 80
2  libsystem_kernel.dylib         0xe28 mach_msg_overwrite + 436
3  libsystem_kernel.dylib         0xc68 mach_msg + 24
4  CoreFoundation                 0x35b1c __CFRunLoopServiceMachPort + 160
5  CoreFoundation                 0x33a14 __CFRunLoopRun + 1208
6  CoreFoundation                 0x33478 CFRunLoopRunSpecific + 608
7  Flutter                        0x2e95e8 (Missing UUID 4c4c44da55553144a1f7c3e66c77eeff)
8  Flutter                        0x2e8c5c (Missing UUID 4c4c44da55553144a1f7c3e66c77eeff)
9  libsystem_pthread.dylib        0x24d4 _pthread_start + 136
10 libsystem_pthread.dylib        0x1a10 thread_start + 8

io.worker.1
0  libsystem_kernel.dylib         0x1b1c __psynch_cvwait + 8
1  libsystem_pthread.dylib        0xfd4 _pthread_cond_wait + 1228
2  Flutter                        0x570fc (Missing UUID 4c4c44da55553144a1f7c3e66c77eeff)
3  Flutter                        0x2e28b0 (Missing UUID 4c4c44da55553144a1f7c3e66c77eeff)
4  libsystem_pthread.dylib        0x24d4 _pthread_start + 136
5  libsystem_pthread.dylib        0x1a10 thread_start + 8

io.worker.2
0  libsystem_kernel.dylib         0x1b1c __psynch_cvwait + 8
1  libsystem_pthread.dylib        0xfd4 _pthread_cond_wait + 1228
2  Flutter                        0x570fc (Missing UUID 4c4c44da55553144a1f7c3e66c77eeff)
3  Flutter                        0x2e28b0 (Missing UUID 4c4c44da55553144a1f7c3e66c77eeff)
4  libsystem_pthread.dylib        0x24d4 _pthread_start + 136
5  libsystem_pthread.dylib        0x1a10 thread_start + 8

io.worker.3
0  libsystem_kernel.dylib         0x1b1c __psynch_cvwait + 8
1  libsystem_pthread.dylib        0xfd4 _pthread_cond_wait + 1228
2  Flutter                        0x570fc (Missing UUID 4c4c44da55553144a1f7c3e66c77eeff)
3  Flutter                        0x2e28b0 (Missing UUID 4c4c44da55553144a1f7c3e66c77eeff)
4  libsystem_pthread.dylib        0x24d4 _pthread_start + 136
5  libsystem_pthread.dylib        0x1a10 thread_start + 8

io.worker.4
0  libsystem_kernel.dylib         0x1b1c __psynch_cvwait + 8
1  libsystem_pthread.dylib        0xfd4 _pthread_cond_wait + 1228
2  Flutter                        0x570fc (Missing UUID 4c4c44da55553144a1f7c3e66c77eeff)
3  Flutter                        0x2e28b0 (Missing UUID 4c4c44da55553144a1f7c3e66c77eeff)
4  libsystem_pthread.dylib        0x24d4 _pthread_start + 136
5  libsystem_pthread.dylib        0x1a10 thread_start + 8

io.worker.5
0  libsystem_kernel.dylib         0x1b1c __psynch_cvwait + 8
1  libsystem_pthread.dylib        0xfd4 _pthread_cond_wait + 1228
2  Flutter                        0x570fc (Missing UUID 4c4c44da55553144a1f7c3e66c77eeff)
3  Flutter                        0x2e28b0 (Missing UUID 4c4c44da55553144a1f7c3e66c77eeff)
4  libsystem_pthread.dylib        0x24d4 _pthread_start + 136
5  libsystem_pthread.dylib        0x1a10 thread_start + 8

io.worker.6
0  libsystem_kernel.dylib         0x1b1c __psynch_cvwait + 8
1  libsystem_pthread.dylib        0xfd4 _pthread_cond_wait + 1228
2  Flutter                        0x570fc (Missing UUID 4c4c44da55553144a1f7c3e66c77eeff)
3  Flutter                        0x2e28b0 (Missing UUID 4c4c44da55553144a1f7c3e66c77eeff)
4  libsystem_pthread.dylib        0x24d4 _pthread_start + 136
5  libsystem_pthread.dylib        0x1a10 thread_start + 8

dart:io EventHandler
0  libsystem_kernel.dylib         0xef0c kevent + 8
1  Flutter                        0x5a1ed4 (Missing UUID 4c4c44da55553144a1f7c3e66c77eeff)
2  Flutter                        0x5cf9c8 (Missing UUID 4c4c44da55553144a1f7c3e66c77eeff)
3  libsystem_pthread.dylib        0x24d4 _pthread_start + 136
4  libsystem_pthread.dylib        0x1a10 thread_start + 8

io.worker.1
0  libsystem_kernel.dylib         0x1b1c __psynch_cvwait + 8
1  libsystem_pthread.dylib        0xfd4 _pthread_cond_wait + 1228
2  Flutter                        0x570fc (Missing UUID 4c4c44da55553144a1f7c3e66c77eeff)
3  Flutter                        0x2e28b0 (Missing UUID 4c4c44da55553144a1f7c3e66c77eeff)
4  libsystem_pthread.dylib        0x24d4 _pthread_start + 136
5  libsystem_pthread.dylib        0x1a10 thread_start + 8

io.worker.2
0  libsystem_kernel.dylib         0x1b1c __psynch_cvwait + 8
1  libsystem_pthread.dylib        0xfd4 _pthread_cond_wait + 1228
2  Flutter                        0x570fc (Missing UUID 4c4c44da55553144a1f7c3e66c77eeff)
3  Flutter                        0x2e28b0 (Missing UUID 4c4c44da55553144a1f7c3e66c77eeff)
4  libsystem_pthread.dylib        0x24d4 _pthread_start + 136
5  libsystem_pthread.dylib        0x1a10 thread_start + 8

io.worker.3
0  libsystem_kernel.dylib         0x1b1c __psynch_cvwait + 8
1  libsystem_pthread.dylib        0xfd4 _pthread_cond_wait + 1228
2  Flutter                        0x570fc (Missing UUID 4c4c44da55553144a1f7c3e66c77eeff)
3  Flutter                        0x2e28b0 (Missing UUID 4c4c44da55553144a1f7c3e66c77eeff)
4  libsystem_pthread.dylib        0x24d4 _pthread_start + 136
5  libsystem_pthread.dylib        0x1a10 thread_start + 8

io.worker.4
0  libsystem_kernel.dylib         0x1b1c __psynch_cvwait + 8
1  libsystem_pthread.dylib        0xfd4 _pthread_cond_wait + 1228
2  Flutter                        0x570fc (Missing UUID 4c4c44da55553144a1f7c3e66c77eeff)
3  Flutter                        0x2e28b0 (Missing UUID 4c4c44da55553144a1f7c3e66c77eeff)
4  libsystem_pthread.dylib        0x24d4 _pthread_start + 136
5  libsystem_pthread.dylib        0x1a10 thread_start + 8

Thread
0  libsystem_pthread.dylib        0x19fc start_wqthread + 438

Thread
0  libsystem_kernel.dylib         0x96d0 __workq_kernreturn + 8
1  libsystem_pthread.dylib        0x19b0 _pthread_wqthread + 364
2  libsystem_pthread.dylib        0x1a04 start_wqthread + 8

com.google.firebase.crashlytics.MachExceptionServer
0  libsystem_kernel.dylib         0x1178 mach_msg2_trap + 8
1  libsystem_kernel.dylib         0xf10 mach_msg2_internal + 80
2  libsystem_kernel.dylib         0xe28 mach_msg_overwrite + 436
3  libsystem_kernel.dylib         0xc68 mach_msg + 24
4  FirebaseCrashlytics            0x1b040 FIRCLSMachExceptionServer + 104
5  libsystem_pthread.dylib        0x24d4 _pthread_start + 136
6  libsystem_pthread.dylib        0x1a10 thread_start + 8

com.apple.NSURLConnectionLoader
0  libsystem_kernel.dylib         0x1178 mach_msg2_trap + 8
1  libsystem_kernel.dylib         0xf10 mach_msg2_internal + 80
2  libsystem_kernel.dylib         0xe28 mach_msg_overwrite + 436
3  libsystem_kernel.dylib         0xc68 mach_msg + 24
4  CoreFoundation                 0x35b1c __CFRunLoopServiceMachPort + 160
5  CoreFoundation                 0x33a14 __CFRunLoopRun + 1208
6  CoreFoundation                 0x33478 CFRunLoopRunSpecific + 608
7  CFNetwork                      0x25a060 estimatedPropertyListSize + 38188
8  Foundation                     0xafde0 __NSThread__start__ + 732
9  libsystem_pthread.dylib        0x24d4 _pthread_start + 136
10 libsystem_pthread.dylib        0x1a10 thread_start + 8

DartWorker
0  libsystem_kernel.dylib         0x1b1c __psynch_cvwait + 8
1  libsystem_pthread.dylib        0x1000 _pthread_cond_wait + 1272
2  Flutter                        0x697558 InternalFlutterGpuTestClass_Method + 750164
3  Flutter                        0x6d2068 InternalFlutterGpuTestClass_Method + 990564
4  Flutter                        0x696f24 InternalFlutterGpuTestClass_Method + 748576
5  libsystem_pthread.dylib        0x24d4 _pthread_start + 136
6  libsystem_pthread.dylib        0x1a10 thread_start + 8

DartWorker
0  libsystem_kernel.dylib         0x1b1c __psynch_cvwait + 8
1  libsystem_pthread.dylib        0x1000 _pthread_cond_wait + 1272
2  Flutter                        0x697558 InternalFlutterGpuTestClass_Method + 750164
3  Flutter                        0x6d2068 InternalFlutterGpuTestClass_Method + 990564
4  Flutter                        0x696f24 InternalFlutterGpuTestClass_Method + 748576
5  libsystem_pthread.dylib        0x24d4 _pthread_start + 136
6  libsystem_pthread.dylib        0x1a10 thread_start + 8

Thread
0  libsystem_pthread.dylib        0x19fc start_wqthread + 438

Thread
0  libsystem_kernel.dylib         0x96d0 __workq_kernreturn + 8
1  libsystem_pthread.dylib        0x19b0 _pthread_wqthread + 364
2  libsystem_pthread.dylib        0x1a04 start_wqthread + 8

DartWorker
0  libsystem_kernel.dylib         0x1b1c __psynch_cvwait + 8
1  libsystem_pthread.dylib        0x1000 _pthread_cond_wait + 1272
2  Flutter                        0x697558 InternalFlutterGpuTestClass_Method + 750164
3  Flutter                        0x62eef0 InternalFlutterGpuTestClass_Method + 322540
4  Flutter                        0x6d209c InternalFlutterGpuTestClass_Method + 990616
5  Flutter                        0x696f24 InternalFlutterGpuTestClass_Method + 748576
6  libsystem_pthread.dylib        0x24d4 _pthread_start + 136
7  libsystem_pthread.dylib        0x1a10 thread_start + 8

DartWorker
0  libsystem_kernel.dylib         0x1b1c __psynch_cvwait + 8
1  libsystem_pthread.dylib        0x1000 _pthread_cond_wait + 1272
2  Flutter                        0x697558 InternalFlutterGpuTestClass_Method + 750164
3  Flutter                        0x6d2068 InternalFlutterGpuTestClass_Method + 990564
4  Flutter                        0x696f24 InternalFlutterGpuTestClass_Method + 748576
5  libsystem_pthread.dylib        0x24d4 _pthread_start + 136
6  libsystem_pthread.dylib        0x1a10 thread_start + 8

DartWorker
0  libsystem_kernel.dylib         0x1b1c __psynch_cvwait + 8
1  libsystem_pthread.dylib        0x1000 _pthread_cond_wait + 1272
2  Flutter                        0x697558 InternalFlutterGpuTestClass_Method + 750164
3  Flutter                        0x6d2068 InternalFlutterGpuTestClass_Method + 990564
4  Flutter                        0x696f24 InternalFlutterGpuTestClass_Method + 748576
5  libsystem_pthread.dylib        0x24d4 _pthread_start + 136
6  libsystem_pthread.dylib        0x1a10 thread_start + 8

DartWorker
0  libsystem_kernel.dylib         0x1b1c __psynch_cvwait + 8
1  libsystem_pthread.dylib        0x1000 _pthread_cond_wait + 1272
2  Flutter                        0x697558 InternalFlutterGpuTestClass_Method + 750164
3  Flutter                        0x6d2068 InternalFlutterGpuTestClass_Method + 990564
4  Flutter                        0x696f24 InternalFlutterGpuTestClass_Method + 748576
5  libsystem_pthread.dylib        0x24d4 _pthread_start + 136
6  libsystem_pthread.dylib        0x1a10 thread_start + 8
SdxCoder commented 7 months ago

No workaround is working for us. We would appreciate if it can be fixed as soon as possible @Milad-Akarie .Thanks

Milad-Akarie commented 7 months ago

Hello @SdxCoder, sorry for not being active these days, I've being super busy. Any ways, popUntil uses Navigator.popUntil so debugging and fixing it might take sometime, however if your goal is to remove all routes and stack but the root you can try router.replaceAll([MyRootRoute]) or router.navigate(MyRootRoute])

SdxCoder commented 7 months ago

Hello @Milad-Akarie , I believe using router.replaceAll([MyRootRoute]) this will pop all the routes and push a new list of route here in this case as root route. I don't want the root route to get disposed and pushed again as we have state associted , this will dispose the state and logic wont work. Correct me if i'm wrong.

router.navigate(MyRootRoute) how this works? I believe it checks the top most route , if route is already present it doesn't push new on top, else it pushes a new route. I don't think it will remove all the routes above. Kindly guide me here.

Milad-Akarie commented 7 months ago

ReplaceAll does not dispose existing pages unless forced to, NavigateTo will pop all routes until first match with target route

SdxCoder commented 7 months ago

Alright thanks @Milad-Akarie . Yup navigate worked.

github-actions[bot] commented 6 months ago

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

olexale commented 6 months ago

A comment for preventing the issue from being automatically closed as the problem is still there.

Milad-Akarie commented 6 months ago

@olexale any idea how to repreduce this?

olexale commented 6 months ago

@Milad-Akarie, unfortunately, I don't have a stable way to reproduce it. There is a problem related to popUntil, adding a delay before and after popUntil significantly reduces the number of crashes, but does not solve the problem completely (plus makes UX worse).

koral-- commented 6 months ago

Here are one of the latest occurrences, maybe that will help: breadcrubms:

navigation { from: PaymentTerminationRoute, state: didPop, to: OrderSummaryRoute } 15:14:48
navigation { from: OrderSummaryRoute, state: didPop, to: ShoppingCartRoute } 15:14:48
navigation { from: ShoppingCartRoute, state: didPop, to: MainRoute } 15:14:48
navigation { from: MainRoute, state: didPush, to: MyDeliveriesRoute } 15:14:48
navigation { from: MyDeliveriesRoute, state: didPop, to: MainRoute } 15:14:49
error StateError: Bad state: Future already completed 15:14:49

Stacktrace:

StateError: Bad state: Future already completed
  File "future_impl.dart", line 35, in _AsyncCompleter.complete
  File "navigator.dart", line 362, in Route.didComplete
  File "navigator.dart", line 340, in Route.didPop
  File "routes.dart", line 76, in OverlayRoute.didPop
  File "routes.dart", line 305, in TransitionRoute.didPop
  File "routes.dart", line 744, in LocalHistoryRoute.didPop
  File "auto_route_navigator.dart", line 74, in AutoRouteNavigatorState.build.<fn>
  File "navigator.dart", line 4996, in NavigatorState.pop
  File "navigator.dart", line 5039, in NavigatorState.popUntil
  File "routing_controller.dart", line 1016, in StackRouter.popUntil
  File "routing_controller.dart", line 1273, in StackRouter.popUntilRouteWithName
  File "order_payment_termination_body.dart", line 66, in OrderPaymentTerminationBody._backToMainPage
Milad-Akarie commented 6 months ago

@koral-- Any thing special in MyDeliveriesRoute?

koral-- commented 6 months ago

Nothing special. Here is the entry in a router: AutoRoute(page: MyDeliveriesRoute.page),

And the generated code:

/// generated route for
/// [_i22.MyDeliveriesPage]
class MyDeliveriesRoute extends _i42.PageRouteInfo<void> {
  const MyDeliveriesRoute({List<_i42.PageRouteInfo>? children})
      : super(
          MyDeliveriesRoute.name,
          initialChildren: children,
        );

  static const String name = 'MyDeliveriesRoute';

  static const _i42.PageInfo<void> page = _i42.PageInfo<void>(name);
}

And the code which caused the exception:

  Future<void> _goToMyDeliveriesPage(BuildContext context, PaymentTerminationCubit cubit) async {
    await _backToMainPage(context, cubit);
    await context.router.push(const MyDeliveriesRoute());
  }

  Future<void> _backToMainPage(BuildContext context, PaymentTerminationCubit cubit) async {
//stripped some async call unrelated to routing
    context.router.popUntilRouteWithName(MainRoute.name);
  }

As you can see, the MyDeliveriesRoute was already pushed (with await) and then popped to the MainPage. But some logic related to previous pop to the same page was still executing asynchronously.

Milad-Akarie commented 6 months ago

@koral-- I still can't reproduce this, are you getting the error everytime you run the code? Are you working with one router or nested?

koral-- commented 6 months ago

There is only one router. The issue occurs randomly. It seems to be a race condition. In most of the cases the async call is able to complete before another the same pop. But sometimes they interleave.

I haven't analyzed the internals of Router and Navigator classes but here are some thoughts:

JamesVu33 commented 5 months ago

I got the same issue log on Firebase crashlytics. I tried to reproduce it in dev env , and then I got another log I hope it related

LOG: [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: 'package:flutter/src/widgets/navigator.dart': Failed assertion: line 5277 pos 12: '!_debugLocked': is not true.

0 _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:51:61)

1 _AssertionError._throwNew (dart:core-patch/errors_patch.dart:40:5)

2 NavigatorState.pop (package:flutter/src/widgets/navigator.dart:5277:12)

3 NavigatorState.popUntil (package:flutter/src/widgets/navigator.dart:5324:7)

4 StackRouter.popUntil (package:auto_route/src/router/controller/routing_controller.dart:1379:42)

5 StackRouter.popUntilRouteWithName (package:auto_route/src/router/controller/routing_controller.dart:1720:5)

6 _EcouponDetailBodyState._stateListen... (package:test/src/modules/ecoupon_detail/presentation/widgets/ecoupon_detail_body.dart:130:28)

7 SuccessfulPage._body. (package:test/src/modules/successful/presen<…>

test on iOS simulator: IP14ProMax - OS 16.4 auto_route: ^7.8.3

Screenshot 2024-03-21 at 10 17 11
bensonarafat commented 4 months ago

Having the same issue.. Adding my comment to get notify about the process on it.

kane-knowby commented 4 months ago

I'm also getting this error popup in Sentry, can't replicate reliably, could be race condition as others suggested

HaidanWeem commented 4 months ago

Having the same issue.

Non-fatal Exception: FlutterError 0 ??? 0x0 _AsyncCompleter.complete (dart:async) 1 ??? 0x0 Route.didComplete + 423 (navigator.dart:423) 2 ??? 0x0 Route.didPop + 401 (navigator.dart:401) 3 ??? 0x0 OverlayRoute.didPop + 77 (routes.dart:77) 4 ??? 0x0 TransitionRoute.didPop + 306 (routes.dart:306) 5 ??? 0x0 LocalHistoryRoute.didPop + 757 (routes.dart:757) 6 ??? 0x0 AutoRouteNavigatorState.build. + 98 (auto_route_navigator.dart:98) 7 ??? 0x0 NavigatorState.pop + 5284 (navigator.dart:5284) 8 ??? 0x0 NavigatorState.popUntil + 5324 (navigator.dart:5324) 9 ??? 0x0 StackRouter.popUntil + 1373 (routing_controller.dart:1373) 10 ??? 0x0 StackRouter.pushAndPopUntil + 1640 (routing_controller.dart:1640)

Device: iPhone 14 Pro Max

Version: auto_route: ^7.8.4 auto_route_generator: ^7.3.2 flutter: 3.19.5

Floul commented 4 months ago

the problem is still there

gazialankus commented 3 months ago

This happens with .pushAndPopUntil() when user acts too quickly (skips two screens by tapping very fast). Happens every time consistently. Also only happens in our release builds and not debug builds.

We used .replace() instead to circumvent this.

github-actions[bot] commented 2 months ago

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

koral-- commented 2 months ago

A comment for preventing the issue from being automatically closed as the problem is still there.

github-actions[bot] commented 1 month ago

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