Bug 51267 - E_RUNTIME_SETVALUE error when setting FontSize on WinRT
Summary: E_RUNTIME_SETVALUE error when setting FontSize on WinRT
Status: CONFIRMED
Alias: None
Product: Forms
Classification: Xamarin
Component: Windows ()
Version: 2.3.4
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-01-06 12:26 UTC by François M
Modified: 2017-07-12 22:50 UTC (History)
7 users (show)

Tags: uwp, winrt, bindings, fontsize ac
Is this bug a regression?: No
Last known good build:


Attachments
repro project (294.75 KB, application/x-zip-compressed)
2017-04-14 19:07 UTC, Jimmy [MSFT]
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 51267 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
CONFIRMED

Comment 1 François M 2017-01-06 12:28:22 UTC
It si called by the EntryRenderer:

Xamarin.Forms.Platform.WinRT.EntryRenderer.UpdateFont():

https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Platform.WinRT/EntryRenderer.cs#L149
Comment 2 Stephane Delcroix 2017-02-15 13:05:00 UTC
Please provide a sample project triggering this issue so we can reproduce it.

Thanks.
Comment 3 Brad Chase 2017-04-12 20:02:36 UTC
I am getting the same error:

E_RUNTIME_SETVALUE
  Source=
  StackTrace:
   at Windows.UI.Xaml.Controls.Control.put_FontSize(Double value)
   at Xamarin.Forms.Platform.UWP.FontExtensions.ApplyFont(Control self, IFontElement element)
   at Xamarin.Forms.Platform.UWP.EntryRenderer.UpdateFont()
   at Xamarin.Forms.Platform.UWP.EntryRenderer.OnElementChanged(ElementChangedEventArgs`1 e)
   at Avmosys.Library.Controls.Renderer.Entry2Renderer.OnElementChanged(ElementChangedEventArgs`1 e) in C:\Projects\Avmosys\Argus.Infrastructure.Library.Controls.Xamarin\Renderer\RendererExtensions.cs:line 58
   at Xamarin.Forms.Platform.UWP.VisualElementRenderer`2.SetElement(VisualElement element)
   at Xamarin.Forms.Platform.UWP.Platform.CreateRenderer(VisualElement element)
   at Xamarin.Forms.Platform.UWP.VisualElementPackager.OnChildAdded(Object sender, ElementEventArgs e)
   at Xamarin.Forms.Platform.UWP.VisualElementPackager.Load()
   at Xamarin.Forms.Platform.UWP.VisualElementRenderer`2.SetElement(VisualElement element)
   at Xamarin.Forms.Platform.UWP.Platform.CreateRenderer(VisualElement element)
   at Xamarin.Forms.Platform.UWP.VisualElementPackager.OnChildAdded(Object sender, ElementEventArgs e)
   at Xamarin.Forms.Platform.UWP.VisualElementPackager.Load()
   at Xamarin.Forms.Platform.UWP.VisualElementRenderer`2.SetElement(VisualElement element)
   at Xamarin.Forms.Platform.UWP.Platform.CreateRenderer(VisualElement element)
   at Xamarin.Forms.Platform.UWP.VisualElementPackager.OnChildAdded(Object sender, ElementEventArgs e)
   at Xamarin.Forms.Platform.UWP.VisualElementPackager.Load()
   at Xamarin.Forms.Platform.UWP.VisualElementRenderer`2.SetElement(VisualElement element)
   at Xamarin.Forms.Platform.UWP.Platform.CreateRenderer(VisualElement element)
   at Xamarin.Forms.Platform.UWP.VisualElementPackager.OnChildAdded(Object sender, ElementEventArgs e)
   at Xamarin.Forms.Element.OnChildAdded(Element child)
   at Xamarin.Forms.VisualElement.OnChildAdded(Element child)
   at Xamarin.Forms.Layout.OnInternalAdded(View view)
   at Xamarin.Forms.Layout.InternalChildrenOnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
   at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
   at System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item)
   at System.Collections.ObjectModel.Collection`1.Add(T item)
   at Xamarin.Forms.TemplateUtilities.OnContentChanged(BindableObject bindable, Object oldValue, Object newValue)
   at Xamarin.Forms.BindableObject.SetValueActual(BindableProperty property, BindablePropertyContext context, Object value, Boolean currentlyApplying, SetValueFlags attributes, Boolean silent)
   at Xamarin.Forms.BindableObject.SetValueCore(BindableProperty property, Object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes)
   at Xamarin.Forms.BindableObject.SetValue(BindableProperty property, Object value, Boolean fromStyle, Boolean checkAccess)
   at Xamarin.Forms.ContentView.set_Content(View value)
Comment 4 Brad Chase 2017-04-12 20:10:34 UTC
The error happens when an invalid fontsize is set on the Entry control.  The best solution will probably do a check to make sure the size is valid.

Or the developer can just use a valid size :).
Comment 5 John Hardman 2017-04-13 12:19:18 UTC
I'm seeing the same thing on 2.3.4 on both UWP and WinRT 8.1.

I'm still investigating, but I think the problem occurs when BindingContext is set to a view model that does not contain FontAttributes, FontFamily and FontSize properties. It looks like the default values are then picked up from FontElement and the renderer for UWP and WinRT does not cope with those defaults.
Comment 6 John Hardman 2017-04-13 13:10:52 UTC
It's slightly more generic than that I think - with BindingContext non-null, if the properties that FontAttributes, FontFamily and FontSize are bound to are not found in the view model identified by BindingContext, the defaults from FontElement are used, and the renderer for UWP and WinRT does not cope with those defaults.
Comment 7 John Hardman 2017-04-13 13:35:50 UTC
Just push this page onto the navigation stack to see the problem on UWP and WinRT:

    public class Bug51267PageView : ContentPage
    {
        public Bug51267PageView()
        {
            Entry entry = new Entry();
            {
                BindingContext = new object();
            };

            entry.SetBinding(Entry.FontAttributesProperty, "FontAttributes");
            entry.SetBinding(Entry.FontFamilyProperty, "FontFamily");
            entry.SetBinding(Entry.FontSizeProperty, "FontSize");

            this.Content = new StackLayout
            {
                VerticalOptions = LayoutOptions.StartAndExpand,
                Children =
                {
                    entry
                }
            }; 
        }
    }
Comment 8 John Hardman 2017-04-13 13:36:35 UTC
Can somebody update the status of this bug to NEW or CONF please, now that repro sample provided.
Comment 9 Samantha Houts [MSFT] 2017-04-13 17:57:29 UTC
Per Comment 8 :)
Comment 10 Jimmy [MSFT] 2017-04-14 19:07:36 UTC
Created attachment 21559 [details]
repro project

I put together a project with the code from comment 8 and I can reproduce the crash. This does appear to be occur when binding Entry.FontSize to a non-existent binding. There is no crash on iOS or Android, just UWP/WinRT.


### Version Tests
2.3.5-pre1  BAD
2.3.4.231   BAD
2.3.3.193   BAD
Comment 11 John Hardman 2017-04-19 17:21:11 UTC
Just noticed a typo in the code above:

            Entry entry = new Entry();
            {
                BindingContext = new object();
            };

should have been:

            Entry entry = new Entry
            {
                BindingContext = new object()
            };

However, the end result in terms of the bug is the same - both throw an exception :-)