-
Notifications
You must be signed in to change notification settings - Fork 28.6k
Android Add to App: Single Engine going from FlutterFragment->FlutterActivity and back #95877
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I believe you're running into the same problem as detailed here: #49950 Essentially, I believe it's an intentional decision to discourage the association of multiple flutter view components with a single cached engine on Android. It seems like the direction they're going in is to encourage the creation of multiple lightweight flutter engines if you need multiple instances of flutter in an add-to-app use case. Here's the original design doc: https://docs.google.com/document/d/1fdKRufqUzQvERcqNIUSq-GdabXc4k8VIsClzRElJ6KY/edit# I ran into this at my job where we were migrating a native app to Flutter and we had some hybrid navigation, and since we were expecting it to be a temporary situation for us, we ended up essentially forking the embedding library and following the customizations that were used to solve this problem in the thaw library: https://github.com/littleGnAl/thaw (this was suggested in a comment in the issue linked above). We then just have to run a diff whenever each time we upgrade flutter to resolve conflicts and make sure that our custom implementation is going to continue to work with the new embeddings. There are other things you can do that help but aren't as thorough. For example, you technically could override The downside there is that you currently can't prevent the engine from detaching from the plugins your flutter app is using (which can be an easy bug to overlook). Going with the solutions in the thaw library above will help you with that. |
Ooh actually just saw this on that issue—looks like something was merged in the past month that might help make this not a problem in an upcoming flutter release: flutter/engine#30202. Doesn't solve your problem immediately, but from what I can tell on an initial read of that code, it seems to be aiming to fix this particular problem, which is phenomenal because it's a huge pain to work around this |
You can refer to the implementation of FlutterBoostFragment. |
@ryanneuroflow |
@willlockwood |
@0xZOne
|
Before the official accepts this PR or proposes a new solution, the following workaround can be considered:
|
@ryanneuroflow |
@ryanneuroflow Yes that sounds correct to me. That's pretty much the same position we were in. In my opinion, multiple engines isn't a good solution there because once you migrate that middle part of your flow to Flutter, you're going to have to rewrite/refactor a lot of stuff to merge those two separate engine experiences into one Flutter app. It was really a non-starter option for us, and I'd suggest that you find a way to work around the single-engine limitation as well, especially given that it looks like they're in progress on a fix. |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
I believe this may be related to: #93905
Thank you!
The text was updated successfully, but these errors were encountered: