-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Better API for Native Embedding and MauiContext creation for it #1718
Comments
Hello, Assuming this issue is about embedding MAUI Pages in native Xamarin.iOS / Xamarin.Android applications then maybe it's worth having a look at this old Xamarin.Forms bug xamarin/Xamarin.Forms#2396 as it had to do with how Android recreates the fragment when the activity is recreated (e.g. after a configuration change), to make sure that it won't reproduce in MAUI. Regards, |
I have a sample repo here showing embedding with multiple windows: https://github.com/mattleibow/EmbeddedMauiApps |
We have a large enterprise mobile application available to internal users, business partners, and customers that we are attempting to port to .NET7 and MAUI from Xamarin iOS\Xamarin Android and Xamarin Forms. Our existing Xamarin approach is using embedded Xamarin Forms and was working very well. We have invested quite a bit of time building up various controls, styles, services, etc. to fairly seamlessly integrate between Xamarin Native and Xamarin Forms. The attempt to migrate to an embedded MAUI use case has been disappointing and very painful. We tried moving to .NET8 once that was released to see if any issues were resolved but the regression (17948) blocked that and we're back on .NET 7. I've commented on or filed a number of bugs that may or may not be resolved by the work proposed here. I'm sure we were not the only ones using embedded Xamarin Forms. With the end of support for Xamarin, we don't have a choice but to go to MAUI and we do not have the option at this time to convert our Xamarin Native apps to "pure" MAUI. Please consider prioritizing this open issue (and any related work) to provide a first class experience for embedded MAUI use cases. Issues we're running into:
|
I am in a very similar situation to @nau-dwb - the Blueye App is a large iOS and Android app, with a mix of Xamarin.iOS/Xamarin.Android and Xamarin.Forms embedding. The development of the app started before Xamarin.Forms were released, and we gradually moved towards Xamarin.Forms by using embedding and building new functionality in Xamarin.Forms. Today, I would guess the app is ~60% Xamarin.Forms and 40% in Xamarin.iOS/Xamarin.Android. Our goal is to move more towards Xamarin gradually.Forms as prep-work for MAUI migration, but I don't think there will be any way around some form of embedding. I can share more details, examples, and screenshots of the architecture if it can help push the priority of this functionality/issue. |
It would be beneficial to include guidelines on setting up window and app contexts, and to make this API public somehow(maybe another package for embedding scenario which gives more API, idk). The reason being, creating window/application context scopes seems to enable hot reload functionality even in embedded scenarios, and it appears to support DynamicResource in embedding contexts (though I could be mistaken about what bare minimum is needed for HotReload exactly, but it does seem to enough to make it work in my experience). Currently, our application is transitioning to MAUI but still relies on native activities/view controllers, alongside MvvmCross (we're planning to shift away from MvvmCross once we've implemented most of the views). We are in the process of rewriting our existing views using XAML and ContentPages. I've set up IPlatformApplication and created application and window contexts (a single context on iOS and one per activity on Android), enabling HotReload. However, this required invoking some APIs through reflection and modifying WindowHandler.MapContent to be non-operative. This approach has significantly expedited our migration, facilitating both HotReload and unload/load events. I believe making these details and functionalities publicly accessible and well-documented would greatly assist others who are considering migrating to MAUI from pure .NET iOS/Android applications. I am still a little bit afraid to include this HotReload/'window setting' code in RELEASE. @nau-dwb, if you are interested, I can make some kind of article/guide on what I have done. |
@artemvalieiev Sure, if you have the time I'd be interested to see the approach you took. Like you, I'm not sure we'd be comfortable including it in an actual release, but it might be an option to keep us moving and workaround some of the other issues we're running into. |
I just want to bump this one. We are still holding off from our MAUI migration due to all the open issues around MAUI embedding. It would be great to get some feedback on priorities for this feature set and where it sits on the MAUI roadmap. |
Same as @follesoe, we have to pause our work until this is resolved. I only hope that we can limp along with Xamarin and the door isn't shut by Apple before embedding works reliably. The end of support date for Xamarin really should be extended. |
@PureWeen if you don't mind me asking why was completed ? it was multiple open linked tasks and issues. |
This is partially helped by #5218
Future design notes:
Make use of the extensions in
MauiContextExtensions
to capture and store the platform app and window for use in other places:MakeApplicationScope
MakeWindowScope
For example, it could be possible to make a new extension method for
MauiApp
:The new extension method just returns a wrapped
MauiApp
that holds the context:Related Issues:
Related PRs:
The text was updated successfully, but these errors were encountered: