auto_route_library icon indicating copy to clipboard operation
auto_route_library copied to clipboard

Child pages are not rendered after exiting a nested initial page with the back gesture and launching from the Android launcher.

Open kouroku-room opened this issue 9 months ago • 9 comments

I do not own an Android device, so I am using an Android emulator to check the operation. Sorry if others have not been able to reproduce this and the behavior is specific to my emulator.

Environment

Android Emulator version 34.2.13 Android Emulator hypervisor driver (installer) version 2.2.0

flutter doctor -v
PS C:\projects\sampleForIssue> flutter doctor -v
[√] Flutter (Channel stable, 3.19.6, on Microsoft Windows [Version 10.0.22631.3447], locale ja-JP)
    • Flutter version 3.19.6 on channel stable at C:\src\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 54e66469a9 (13 days ago), 2024-04-17 13:08:03 -0700
    • Engine revision c4cd48e186
    • Dart version 3.3.4
    • DevTools version 2.31.1

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 35.0.0-rc3)
    • Android SDK at C:\Users\sugur\AppData\Local\Android\sdk
    • Platform android-34, build-tools 35.0.0-rc3
    • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 17.0.10+0--11572160)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.9.4)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.9.34714.143
    • Windows 10 SDK version 10.0.22000.0

[√] Android Studio (version 2023.3)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.10+0--11572160)

[√] VS Code (version 1.88.1)
    • VS Code at C:\Users\sugur\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension can be installed from:
       https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[√] Connected device (4 available)
    • sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64    • Android 14 (API 34) (emulator)
    • Windows (desktop)            • windows       • windows-x64    • Microsoft Windows [Version 10.0.22631.3447]
    • Chrome (web)                 • chrome        • web-javascript • Google Chrome 124.0.6367.91
    • Edge (web)                   • edge          • web-javascript • Microsoft Edge 124.0.2478.67

[√] Network resources
    • All expected network resources are available.

• No issues found!

Example Code

Example Code

pubspec.yaml:

name: sample_for_issue
description: "A new Flutter project."
publish_to: 'none'
version: 1.0.0+1
environment:
  sdk: '>=3.3.3 <4.0.0'

dependencies:
  flutter:
    sdk: flutter
  cupertino_icons: ^1.0.8
  auto_route: 8.1.3

dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_lints: ^3.0.2
  auto_route_generator: ^8.0.0
  build_runner: ^2.4.9

flutter:
  uses-material-design: true

app_router.dart:

import 'package:auto_route/auto_route.dart';

import 'main.dart';

part 'app_router.gr.dart';

@AutoRouterConfig(replaceInRouteName: 'Page,Route')
class AppRouter extends _$AppRouter {
  @override
  List<AutoRoute> get routes => [
        AutoRoute(
          page: ParentRoute.page,
          initial: true,
          children: [
            AutoRoute(page: ChildRoute.page, initial: true),
          ],
        ),
      ];
}

main.dart:

import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart';

import 'app_router.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  MyApp({super.key});

  final _appRouter = AppRouter();

  @override
  Widget build(BuildContext context) {
    return MaterialApp.router(
      theme: ThemeData(
        useMaterial3: true,
      ),
      routerConfig: _appRouter.config(),
    );
  }
}

@RoutePage()
class ParentPage extends StatelessWidget {
  const ParentPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Stack(
      fit: StackFit.expand,
      children: [
        Container(
          color: Theme.of(context).colorScheme.secondaryContainer,
        ),
        const AutoRouter(),
      ],
    );
  }
}

@RoutePage()
class ChildPage extends StatelessWidget {
  const ChildPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.transparent,
      appBar: AppBar(
        title: const Text('Child'),
      ),
      body: const Center(
        child: Column(
          children: [
            Text(
              'Child',
            ),
          ],
        ),
      ),
    );
  }
}

Procedure

  1. Install the app and launch it (either by using the Run button in Android Studio or by installing the built Release APK, in both cases the problem occurred). ChildPage is displayed at this time.

  2. Perform the back process (whether by back key or gesture by swiping, the bug occurred in both cases).

  3. Tap the app in the launcher.

-> ParentPage is rendered, but ChildPage is not.

https://github.com/Milad-Akarie/auto_route_library/assets/57855128/c01a8e5c-960e-481d-b1c7-f7e2b2b65c64

Log(~ parts is my added)
Launching lib\main.dart on sdk gphone64 x86 64 in debug mode...
Running Gradle task 'assembleDebug'...
√  Built build\app\outputs\flutter-apk\app-debug.apk.
Installing build\app\outputs\flutter-apk\app-debug.apk...
Debug service listening on ws://127.0.0.1:59902/WsRGL123o4A=/ws
Syncing files to device sdk gphone64 x86 64...

 ~ back pressed ~

D/EGL_emulation(18126): app_time_stats: avg=12504.26ms min=12.23ms max=24996.28ms count=2
W/WindowOnBackDispatcher(18126): sendCancelIfRunning: isInProgress=falsecallback=android.view.ViewRootImpl$$ExternalSyntheticLambda17@2140e8e
W/ample_for_issue(18126): Cleared Reference was only reachable from finalizer (only reported once)

 ~ app icon tapped on launcher ~

W/OpenGLRenderer(18126): Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
W/OpenGLRenderer(18126): Failed to initialize 101010-2 format, error = EGL_SUCCESS
E/OpenGLRenderer(18126): Unable to match the desired swap behavior.
E/emuglGLESv2_enc(18126): device/generic/goldfish-opengl/system/GLESv2_enc/GL2Encoder.cpp:s_glGetUniformLocation:2206 GL error 0x502
E/emuglGLESv2_enc(18126): device/generic/goldfish-opengl/system/GLESv2_enc/GL2Encoder.cpp:s_glGetUniformLocation:2206 GL error 0x502
E/emuglGLESv2_enc(18126): device/generic/goldfish-opengl/system/GLESv2_enc/GL2Encoder.cpp:s_glGetUniformLocation:2206 GL error 0x502
E/emuglGLESv2_enc(18126): device/generic/goldfish-opengl/system/GLESv2_enc/GL2Encoder.cpp:s_glGetUniformLocation:2206 GL error 0x502
E/emuglGLESv2_enc(18126): device/generic/goldfish-opengl/system/GLESv2_enc/GL2Encoder.cpp:s_glGetUniformLocation:2206 GL error 0x502
E/emuglGLESv2_enc(18126): device/generic/goldfish-opengl/system/GLESv2_enc/GL2Encoder.cpp:s_glGetUniformLocation:2206 GL error 0x502
E/emuglGLESv2_enc(18126): device/generic/goldfish-opengl/system/GLESv2_enc/GL2Encoder.cpp:s_glGetUniformLocation:2206 GL error 0x502
E/emuglGLESv2_enc(18126): device/generic/goldfish-opengl/system/GLESv2_enc/GL2Encoder.cpp:s_glGetUniformLocation:2206 GL error 0x502
E/emuglGLESv2_enc(18126): device/generic/goldfish-opengl/system/GLESv2_enc/GL2Encoder.cpp:s_glGetUniformLocation:2206 GL error 0x502
E/emuglGLESv2_enc(18126): device/generic/goldfish-opengl/system/GLESv2_enc/GL2Encoder.cpp:s_glGetUniformLocation:2206 GL error 0x502

This may be related to a bug in the emulator, as the following logs are displayed.

https://github.com/flutter/flutter/issues/146890

E/emuglGLESv2_enc(17550): device/generic/goldfish-opengl/system/GLESv2_enc/GL2Encoder.cpp:s_glGetUniformLocation:2183 GL error 0x502

According to this Issue (https://github.com/flutter/flutter/issues/146890), Android Emulator version 35 is the cause of the bug and that version has already been removed. However, I am encountering this bug (#1947) with Android Emulator version 34.2.13.

Is this a bug that other users are also experiencing with the emulator? And is it a bug that does not occur on the actual device?

kouroku-room avatar May 01 '24 04:05 kouroku-room