Image with FontImageSource not displaying expected font icon in Android and embedded MAUI when Finish called on initial launch Activity. #19846
Labels
area-controls-image
Image control
area-fonts
Custom fonts and Font related API's
migration-compatibility
Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert
platform/android 🤖
t/bug
Something isn't working
Description
We're trying to migrate our Xamarin Android and Xamarin iOS application with embedded Xamarin Forms to .NET Android and iOS with embedded MAUI. I'm running into an issue in Android with Images on MAUI pages that have a font image source using a font icon file to where the image does not display.
Per some of the examples on using embedded MAUI, we initialize all the MAUI code in the launch Android Activity and save off the instance of MauiContext in a singleton for use elsewhere in the application. When converting a MAUI page to an Android Fragment, we need to provide the MAUI Context instance.
Our Android application's initial launch Activity is for a login page. Once the user authenticates, we create a new Intent for a "landing page" activity and invoke StartActivity to display this to the user. We then invoke Finish() on the initial login launch activity.
From what I've been able to determine, the fact that we invoke Finish on the launch activity that also initializes the MAUI context is the root cause of this issue. This seems like a fairly common use case though (an initial login activity that is completed after authentication once a new activity is started).
I'm not sure if any of the changes proposed in Issue 1718 would resolve this? Or if this is working as expected\designed if there's better guidance out there for how to handle the embedded MAUI experience?
This worked fine in Xamarin Forms. iOS is not impacted though that's likely due to difference in how we start up and initialize the two platforms.
This does not repro in Android if we don't invoke Finish on the launch activity. If we recreate the MAUI context in Android before navigating to the page with the font image source then it works as well.
Either
simple-maui-embedded
orsimple-android-embedded
in the provided repo have options to launch the page with it working or failing. You can also comment out Finish() in the main activity to see how that impacts it too.Steps to Reproduce
Expected: The page displays with the expected image displaying the font icon.
Actual: No font icon is displayed.
Option 1 to have it work:
Option 2 to have it work:
Either
simple-maui-embedded
orsimple-android-embedded
in the provided repo can be used to further explore this.Link to public reproduction project repository
https://github.com/nau-dwb/maui-embedded-use-issues/tree/main
Version with bug
Unknown/Other
Is this a regression from previous behavior?
Yes, this used to work in Xamarin.Forms
Last version that worked well
Unknown/Other
Affected platforms
Android, I was not able test on other platforms
Affected platform versions
Android 26+ with .NET 7
Did you find any workaround?
Not a workaround per say, but two scenarios where this will work:
Don't invoke Finish() on the initial activity that created the MAUI Context that's being used throughout the application. This is not an option for us.
Reinitialize the MAUI stuff and create a new instance of MauiContext on the second Activity. I don't know what the other implications or side effects of this could be but it seems to run counter to all the examples I've seen on the use of embedded MAUI.
Relevant log output
No response
The text was updated successfully, but these errors were encountered: