pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/flutter/flutter/pull/182963

"https://github.githubassets.com/assets/actions-109fb3a41bacb1c2.css" /> [Android] Avoid plugin auto-registration during FlutterFragmentActivity recreate timing window by littleGnAl · Pull Request #182963 · flutter/flutter · GitHub
Skip to content

[Android] Avoid plugin auto-registration during FlutterFragmentActivity recreate timing window#182963

Open
littleGnAl wants to merge 1 commit intoflutter:masterfrom
littleGnAl:littlegnal/fix-flutterfragmentactivity-restore-plugin-registration
Open

[Android] Avoid plugin auto-registration during FlutterFragmentActivity recreate timing window#182963
littleGnAl wants to merge 1 commit intoflutter:masterfrom
littleGnAl:littlegnal/fix-flutterfragmentactivity-restore-plugin-registration

Conversation

@littleGnAl
Copy link
Contributor

This PR fixes an Android embedding timing issue in FlutterFragmentActivity during Activity recreation.

When an Activity is being recreated, FragmentManager can restore/attach an existing FlutterFragment before ensureFlutterFragmentCreated() refreshes the flutterFragment field.
In that window, configureFlutterEngine() may run with flutterFragment == null, miss the injected-engine guard, and incorrectly call GeneratedPluginRegister.registerGeneratedPlugins(...).

That can lead to unintended plugin lifecycle behavior in real apps.

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

@littleGnAl littleGnAl requested a review from a team as a code owner February 26, 2026 21:11
@github-actions github-actions bot added platform-android Android applications specifically engine flutter/engine related. See also e: labels. team-android Owned by Android platform team labels Feb 26, 2026
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request addresses a timing issue in FlutterFragmentActivity during activity recreation, which could lead to incorrect plugin auto-registration. The fix involves modifying configureFlutterEngine to explicitly check for an existing FlutterFragment from the FragmentManager if the activity's flutterFragment field is not yet populated. This prevents GeneratedPluginRegister.registerGeneratedPlugins from being called unnecessarily. The change is accompanied by two new unit tests: one to specifically validate the new logic in configureFlutterEngine, and another integration test using ActivityScenario to verify the fix during activity recreation with a cached engine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

engine flutter/engine related. See also e: labels. platform-android Android applications specifically team-android Owned by Android platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy