alibaba / alibaba/flutter_boost

Android:FlutterBoostFragment 里面有PlatformView时候,切到另外一个Tab的FlutterBoostFragment 会crash

Open
#1,755 19 comments 3 reactions 0 assignees View on GitHub
Dominant language
Dart
Stars
7.2k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

## Steps to Reproduce
1.在 flutterboost example工程 修改 “main dart”,
把tab_message修改调到example工程里面的NativeViewExample页面
`

tab_message': (settings, uniqueId) {
return PageRouteBuilder(

settings: settings,

pageBuilder: (_, __, ___) =>

NativeViewExample());

}
`
2. run example 工程起来 进入 “open flutter fragment page”
3. 切换到 朋友Tab 必崩

**Flutter Boost Version**
4.2.0
**Target Platform:**
Android
**Target OS version/browser:**
Android 10
**Devices:**
荣耀畅玩 9A

## Logs
java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
at android.view.ViewGroup.addViewInner(ViewGroup.java:5327)
at android.view.ViewGroup.addView(ViewGroup.java:5156)
at android.view.ViewGroup.addView(ViewGroup.java:5096)
at android.view.ViewGroup.addView(ViewGroup.java:5069)
at io.flutter.plugin.platform.PlatformViewsController.attachToView(PlatformViewsController.java:747)
at io.flutter.embedding.android.FlutterView.attachToFlutterEngine(FlutterView.java:1215)
at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onCreateView(FlutterActivityAndFragmentDelegate.java:337)
at io.flutter.embedding.android.FlutterFragment.onCreateView(FlutterFragment.java:806)
at com.idlefish.flutterboost.containers.FlutterBoostFragment.onCreateView(FlutterBoostFragment.java:92)
at com.idlefish.flutterboost.example.tab.FriendFlutterFragment.onCreateView(FriendFlutterFragment.java:19)
at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2600)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:881)
at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1238)
at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:434)
at androidx.fragment.app.FragmentManagerImpl.executeOps(FragmentManagerImpl.java:2079)
at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:1869)
at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerImpl.java:1824)
at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManagerImpl.java:1727)
at androidx.fragment.app.FragmentManagerImpl$2.run(FragmentManagerImpl.java:150)
at android.os.Handler.handleCallback(Handler.java:900)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:219)
at android.app.ActivityThread.main(ActivityThread.java:8349)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1055)

```
• Flutter version 3.3.3 on channel stable at /Users/liuyc/fvm/versions/3.3.3
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 18a827f393 (6 weeks ago), 2022-09-28 10:03:14 -0700
• Engine revision 5c984c26eb
• Dart version 2.18.2
• DevTools version 2.15.0
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the crash in the example project's main.dart using NativeViewExample and switching to the Friends tab. Start from FlutterBoostFragment.onCreateView and the PlatformViewsController.attachToView stack-trace entry. Done means switching between FlutterBoostFragment tabs with a PlatformView no longer throws the child-already-has-a-parent exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, dart, flutter
Domain
mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.