[Bug] Using fonts from a non-UI thread results in exception with HRESULT 0x8001010E (RPC_R_WRONG_THREAD) on UWP
#8840 aperta il 10 dic 2019
Metriche repository
- Star
- (5644 stelle)
- Metriche merge PR
- (Nessuna PR mergiata in 30 g)
Descrizione
Description
Using fonts from a non-UI thread, even when the font is not being used in a page's UI hierarchy, results in an exception with HRESULT 0x8001010E (RPC_R_WRONG_THREAD) on UWP.
This prevents pages being prepared away from the UI thread before they are actually required, meaning that an obvious performance improvement technique cannot be used on UWP if fonts are used at all (the same problem happens if XAML is used as well).
Steps to Reproduce
-
Add a Button to a page, with the Button defined as follows:
new Button { Text = "Use a font on a non-UI thread", Command = new Command(() => { Task.Run(() => { Xamarin.Forms.Label label = new Xamarin.Forms.Label { Text = "Hello", FontAttributes = FontAttributes.Italic }; }); }) } -
Run the code and press the Button
-
The exception occurs, even though the View with the FontAttribute being set is not hooked into the UI hierarchy.
Expected Behavior
No exception. Font-related properties should be set as per the code.
Actual Behavior
Exception with HRESULT 0x8001010E (RPC_R_WRONG_THREAD)
Basic Information
- Version with issue: 4.3.0.991211 (but this has been a problem for a long time)
- IDE: VS2019
- Platform Target Frameworks:
- UWP: 18362