flutter_boost icon indicating copy to clipboard operation
flutter_boost copied to clipboard

flutter_boost 4.0.3 Tab + 多个 FlutterBoostFragment 页面退到后台再返回前台时显示的 FlutterBoostFragment 错误

Open ynnekj opened this issue 2 years ago • 3 comments

Steps to Reproduce

A small application to reproduce the bug(最小化可复现的demo)

  1. flutter_boost 4.0.3 版本中的 Example(tab_example)也可复现该问题
  2. 进入 tab_example 页面后点击底部几个 Tab 让多个 FlutterBoostFragment 都加载一次,然后选择第一个 Tab(消息), 点击 open native page 按钮打开一个 Native 页面(或按 Home 键将应用退到后台),之后在返回 tab_example 页面,发现显示的是 第二个 tab(朋友)对应的 FlutterBoostFragment 。

image

Flutter Boost Version: 4.0.3 Target Platform: Android Target OS version/browser: Android 8.0 Devices: Galaxy S9

Logs

add your crash log or something else.

[✓] Flutter (Channel unknown, 3.0.5, on macOS 12.5 21G72 darwin-x64, locale zh-Hans-CN)
    • Flutter version 3.0.5 at /Users/jkenny/flutter
    • Upstream repository unknown
    • Framework revision f1875d570e (6 weeks ago), 2022-07-13 11:24:16 -0700
    • Engine revision e85ea0e79c
    • Dart version 2.17.6
    • DevTools version 2.12.2
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/jkenny/Library/Android/sdk
    • Platform android-33, build-tools 31.0.0
    • ANDROID_HOME = /Users/jkenny/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.4.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • 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 11.0.11+0-b60-7590822)

ynnekj avatar Aug 25 '22 14:08 ynnekj

遇到过类似的情况, 我们App的结构是首页tabhost添加了四个Fragment, 第三个tab中嵌入了Flutter,使用Viewpager+Fragment+FlutterBoostFragment,在Flutter中点击打开原生页面,返回应该会回到当前FlutterboostFragment,实际上却变成了其他的FlutterBoostFragment,断点发现,返回后,FlutterBoost会同时触发多个Fragment的onresume或setUserVisibleHint

目前我们是这么处理的,但还会有其他问题,比如闪现其他FlutterBoostFrament,再显示当前FlutterBoostFragment //继承FlutterBoostFragment override fun onResume() { super.onResume() if (parentFragment?.isHidden == true || isHidden) { return; } if (userVisibleHint) { Handler().postDelayed({ onHiddenChanged(false) }, 0) } }

hoooou avatar Aug 26 '22 04:08 hoooou

https://user-images.githubusercontent.com/26625149/187635978-dcd6256f-4b49-4fce-863d-892ffda71337.mp4

在Pixel 4a上测试没有复现问题。@ynnekj 你用什么手机测试的?

flutter doctor -v
[✓] Flutter (Channel main, 3.1.0-0.0.pre.2592, on macOS 12.0.1 21A559 darwin-x64, locale zh-Hans-CN)
    • Flutter version 3.1.0-0.0.pre.2592 on channel main at /Users/zero/development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 069f504297 (7 hours ago), 2022-08-30 18:20:09 -0700
    • Engine revision 0ef08a8525
    • Dart version 2.19.0 (build 2.19.0-152.0.dev)
    • DevTools version 2.16.0

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0-rc1)
    • Android SDK at /Users/zero/Library/Android/sdk
    • Platform android-33, build-tools 33.0.0-rc1
    • ANDROID_HOME = /Users/zero/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 13C100
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • 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 11.0.11+0-b60-7590822)

[✓] VS Code (version 1.70.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (4 available)
    • Pixel 4a (mobile) • 30.103.233.170:24023                     • android-arm64  • Android 13 (API 33)
    • iPhone (mobile)   • 50131fb4dcef9d96405ec953e272bd5c24468370 • ios            • iOS 15.0 19A346
    • macOS (desktop)   • macos                                    • darwin-x64     • macOS 12.0.1 21A559 darwin-x64
    • Chrome (web)      • chrome                                   • web-javascript • Google Chrome 104.0.5112.101

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

0xZOne avatar Aug 31 '22 08:08 0xZOne

demo.mp4 在Pixel 4a上测试没有复现问题。@ynnekj 你用什么手机测试的?

flutter doctor -v

用了几部手机测试

下面 3 部显示正常: • M2012K11AC (mobile) • 7e09e08 • android-arm64 • Android 11 (API 30) • Redmi K20 Pro Premium Edition (mobile) • 77c468fb • android-arm64 • Android 11 (API 30) • TNY AL00 (mobile) • RPG0218B23003909 • android-arm64 • Android 10 (API 29)

下面 3 部 Galaxy S9、Galaxy S8、OPPO 都出现了这个问题: • SM G960U (mobile) • 4749475233343098 • android-arm64 • Android 8.0.0 (API 26) • SM G9500 (mobile) • 9887bc355545493748 • android-arm64 • Android 7.0 (API 24) • PBAM00 (mobile) • 4e7cd684 • android-arm64 • Android 8.1.0 (API 27)

可能是 Android 8.1.0 (API 27) 以下版本会出现问题。

flutter doctor -v

[✓] Flutter (Channel stable, 3.0.5, on macOS 12.5 21G72 darwin-x64, locale zh-Hans-CN)
    • Flutter version 3.0.5 at /Users/jkenny/flutter_3.0.5
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision f1875d570e (8 weeks ago), 2022-07-13 11:24:16 -0700
    • Engine revision e85ea0e79c
    • Dart version 2.17.6
    • DevTools version 2.12.2
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/jkenny/Library/Android/sdk
    • Platform android-33, build-tools 31.0.0
    • ANDROID_HOME = /Users/jkenny/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.4.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • 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 11.0.11+0-b60-7590822)

[✓] IntelliJ IDEA Ultimate Edition (version 2020.1.4)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    • 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

[✓] VS Code (version 1.67.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (3 available)
    • SM G960U (mobile) • 4749475233343098 • android-arm64  • Android 8.0.0 (API 26)
    • macOS (desktop)   • macos            • darwin-x64     • macOS 12.5 21G72 darwin-x64
    • Chrome (web)      • chrome           • web-javascript • Google Chrome 104.0.5112.101

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

ynnekj avatar Sep 06 '22 10:09 ynnekj

+1

mosentest avatar Oct 12 '22 09:10 mosentest