-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Bug] [UWP] Setting the FontFamily crashes a multi-window app #11705
Comments
Another bug (which could go into its own issue if needed)The secondary window does not resize its I don't know exactly why this happens, but my guess is that it is related to this code: Xamarin.Forms/Xamarin.Forms.Platform.UAP/PageExtensions.cs Lines 72 to 75 in 29b92aa
My current workaround is to update the Xamarin.Forms/Xamarin.Forms.ControlGallery.WindowsUniversal/SecondaryWindowService.cs Line 29 in 29b92aa
Before this line, I added: Window.Current.SizeChanged += (sender, args) =>
{
instance.Layout(new Rectangle(0, 0, args.Size.Width, args.Size.Height));
}; With that, the page is resized accordingly. |
Thanks @KPixel , did a PR your recommendations. |
Awesome. I will continue the discussion on the PR. |
Description
Since #2432, Xamarin.Forms supports creating apps with multiple windows in UWP.
However, if we use the same custom font on these windows, then we get an exception when trying to create the secondary windows.
Steps to Reproduce
The Control Gallery already has a multi-window sample, we just need to update it to set a custom FontFamily:
Xamarin.Forms/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2482.cs
Line 88 in 29b92aa
After this line, add:
Expected Behavior
The app should create as many windows as we want.
Actual Behavior
The app crashes when we try to create its third window.
Basic Information
Solution
This issue is caused by the fact that fonts are cached; so they end up being shared by all windows (which is not allowed):
Xamarin.Forms/Xamarin.Forms.Platform.UAP/FontExtensions.cs
Line 14 in 719fc7a
The solution should be to change that cache to be thread-static:
Then, instantiate it before this line:
Xamarin.Forms/Xamarin.Forms.Platform.UAP/FontExtensions.cs
Line 96 in 719fc7a
That should be enough.
The text was updated successfully, but these errors were encountered: