dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.27k stars 1.76k forks source link

[iOS] Issue when using BindableLayout and Entry/Editor #15937

Closed juniorsaraviao closed 1 year ago

juniorsaraviao commented 1 year ago

Description

I'm using a StackLayout with BindableLayout.ItemsSource to show Entry or Editor. However, the app throws an exception:

System.ArgumentNullException: Value cannot be null. (Parameter 'fromPosition')

Screenshot 2023-06-29 at 18 44 52

Steps to Reproduce

  1. Create a .NET Maui project.
  2. Add the following XAML code.
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="MauiSample.MainPage">

    <ScrollView>
        <VerticalStackLayout
            Spacing="25"
            Padding="30,0"
            VerticalOptions="Center">

            <StackLayout Margin="10"
                         VerticalOptions="Center"
                         BindableLayout.ItemsSource="{Binding CustomList}">
                <BindableLayout.ItemTemplate>
                    <DataTemplate>
                        <Grid Margin="0,0,0,20"
                              Padding="0"
                              RowSpacing="0"
                              ColumnSpacing="0">
                            <Entry Text="{Binding Name}"
                                   MaxLength="{Binding MaxLength}"
                                   Keyboard="{Binding KeyboardType}"/>

                            <!--Same issue using Editor-->
                            <!--<Editor Text="{Binding Name}"
                                   MaxLength="{Binding MaxLength}"
                                   Keyboard="{Binding KeyboardType}"/>-->
                        </Grid>
                    </DataTemplate>
                </BindableLayout.ItemTemplate>
            </StackLayout>

            <Image
                Source="dotnet_bot.png"
                SemanticProperties.Description="Cute dot net bot waving hi to you!"
                HeightRequest="200"
                HorizontalOptions="Center" />

            <Label
                Text="Hello, World!"
                SemanticProperties.HeadingLevel="Level1"
                FontSize="32"
                HorizontalOptions="Center" />

            <Label
                Text="Welcome to .NET Multi-platform App UI"
                SemanticProperties.HeadingLevel="Level2"
                SemanticProperties.Description="Welcome to dot net Multi platform App U I"
                FontSize="18"
                HorizontalOptions="Center" />

            <Button
                x:Name="CounterBtn"
                Text="Click me"
                SemanticProperties.Hint="Counts the number of times you click"
                Clicked="OnCounterClicked"
                HorizontalOptions="Center" />

        </VerticalStackLayout>
    </ScrollView>

</ContentPage>
  1. Add the following code behind
using System.Collections.ObjectModel;

namespace MauiSample;

public class CustomItem
{
    public string Name { get; set; }
    public double MaxLength { get; set; }
    public Keyboard KeyboardType { get; set; }
}

public partial class MainPage : ContentPage
{
    int count = 0;
    public ObservableCollection<CustomItem> CustomList { get; set; }

    public MainPage()
    {
        InitializeComponent();
        CustomList = new ObservableCollection<CustomItem>();
        AddCustomItems();
        BindingContext = this;
    }

    void AddCustomItems()
    {
        CustomList.Clear();

        for (int i = 0; i < 10; i++)
        {
            CustomList.Add(new CustomItem
            {
                MaxLength = 10,
                KeyboardType = Keyboard.Email,
                Name = "my value: " + i
            });
        }

  //      CustomList.Add(new CustomItem { Name = "Test1", MaxLength = 20, KeyboardType = Keyboard.Email });
        //CustomList.Add(new CustomItem { Name = "Test2", MaxLength = 30, KeyboardType = Keyboard.Plain });
        //CustomList.Add(new CustomItem { Name = "Test3", MaxLength = 10, KeyboardType = Keyboard.Numeric });
        //CustomList.Add(new CustomItem { Name = "Test4", MaxLength = 23, KeyboardType = Keyboard.Default });
    }

    private void OnCounterClicked(object sender, EventArgs e)
    {
        count++;

        if (count == 1)
            CounterBtn.Text = $"Clicked {count} time";
        else
            CounterBtn.Text = $"Clicked {count} times";

        SemanticScreenReader.Announce(CounterBtn.Text);
    }
}
  1. Run the project and the app will crash.

Link to public reproduction project repository

https://github.com/juniorsaraviao/MauiSample

Version with bug

7.0.86

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

iOS 15.2 and up

Did you find any workaround?

No

Relevant log output

Unhandled Exception:
System.ArgumentNullException: Value cannot be null. (Parameter 'fromPosition')
   at ObjCRuntime.ThrowHelper.ThrowArgumentNullException(String argumentName)
   at ObjCRuntime.NativeObjectExtensions.GetNonNullHandle(INativeObject self, String argumentName)
   at UIKit.UITextField.GetTextRange(UITextPosition fromPosition, UITextPosition toPosition)
   at Microsoft.Maui.Platform.TextInputExtensions.SetTextRange(IUITextInput platformView, Int32 start, Int32 selectedTextLength)
   at Microsoft.Maui.Controls.Platform.TextExtensions.UpdateText(UITextField textField, InputView inputView)
   at Microsoft.Maui.Controls.Entry.MapText(IEntryHandler handler, Entry entry)
   at Microsoft.Maui.Controls.Entry.MapText(EntryHandler handler, Entry entry)
   at Microsoft.Maui.PropertyMapper`2.<>c__DisplayClass5_0[[Microsoft.Maui.Controls.Entry, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Handlers.EntryHandler, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<Add>b__0(IElementHandler h, IElement v)
   at Microsoft.Maui.PropertyMapper.UpdatePropertyCore(String key, IElementHandler viewHandler, IElement virtualView)
   at Microsoft.Maui.PropertyMapper.UpdateProperties(IElementHandler viewHandler, IElement virtualView)
   at Microsoft.Maui.Handlers.ElementHandler.SetVirtualView(IElement view)
   at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.IEntry, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.MauiTextField, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IView view)
   at Microsoft.Maui.Handlers.EntryHandler.SetVirtualView(IView view)
   at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.IEntry, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.MauiTextField, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view)
   at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler)
   at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value)
   at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value)
   at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context)
   at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context)
   at Microsoft.Maui.Handlers.LayoutHandler.SetVirtualView(IView view)
   at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.ILayout, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.LayoutView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view)
   at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler)
   at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value)
   at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value)
   at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context)
   at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context)
   at Microsoft.Maui.Handlers.LayoutHandler.SetVirtualView(IView view)
   at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.ILayout, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.LayoutView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view)
   at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler)
   at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value)
   at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value)
   at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context)
   at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context)
   at Microsoft.Maui.Handlers.LayoutHandler.SetVirtualView(IView view)
   at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.ILayout, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.LayoutView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view)
   at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler)
   at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value)
   at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value)
   at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context)
   at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context)
   at Microsoft.Maui.Handlers.ScrollViewHandler.UpdateContentView(IScrollView scrollView, IScrollViewHandler handler)
   at Microsoft.Maui.Handlers.ScrollViewHandler.MapContent(IScrollViewHandler handler, IScrollView scrollView)
   at Microsoft.Maui.PropertyMapper`2.<>c__DisplayClass5_0[[Microsoft.Maui.IScrollView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Handlers.IScrollViewHandler, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<Add>b__0(IElementHandler h, IElement v)
   at Microsoft.Maui.PropertyMapper.UpdatePropertyCore(String key, IElementHandler viewHandler, IElement virtualView)
   at Microsoft.Maui.PropertyMapper.UpdateProperties(IElementHandler viewHandler, IElement virtualView)
   at Microsoft.Maui.Handlers.ElementHandler.SetVirtualView(IElement view)
   at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.IScrollView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[UIKit.UIScrollView, Microsoft.iOS, Version=16.4.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065]].SetVirtualView(IView view)
   at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.IScrollView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[UIKit.UIScrollView, Microsoft.iOS, Version=16.4.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065]].SetVirtualView(IElement view)
   at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler)
   at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value)
   at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value)
   at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context)
   at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context)
   at Microsoft.Maui.Handlers.ContentViewHandler.UpdateContent(IContentViewHandler handler)
   at Microsoft.Maui.Handlers.ContentViewHandler.MapContent(IContentViewHandler handler, IContentView page)
   at Microsoft.Maui.PropertyMapper`2.<>c__DisplayClass5_0[[Microsoft.Maui.IContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Handlers.IContentViewHandler, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<Add>b__0(IElementHandler h, IElement v)
   at Microsoft.Maui.PropertyMapper.UpdatePropertyCore(String key, IElementHandler viewHandler, IElement virtualView)
   at Microsoft.Maui.PropertyMapper.UpdateProperties(IElementHandler viewHandler, IElement virtualView)
   at Microsoft.Maui.Handlers.ElementHandler.SetVirtualView(IElement view)
   at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.IContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.ContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IView view)
   at Microsoft.Maui.Handlers.ContentViewHandler.SetVirtualView(IView view)
   at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.IContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.ContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view)
   at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler)
   at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value)
   at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value)
   at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context)
   at Microsoft.Maui.Platform.ViewExtensions.ToHandler(IView view, IMauiContext context)
   at Microsoft.Maui.Controls.Platform.Compatibility.ShellSectionRootRenderer.SetPageRenderer(Page page, ShellContent shellContent)
   at Microsoft.Maui.Controls.Platform.Compatibility.ShellSectionRootRenderer.LoadRenderers()
   at Microsoft.Maui.Controls.Platform.Compatibility.ShellSectionRootRenderer.ViewDidLoad()
   at UIKit.UIApplication.UIApplicationMain(Int32 argc, String[] argv, IntPtr principalClassName, IntPtr delegateClassName)
   at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass)
   at MauiSample.Program.Main(String[] args) in /Users/juniorsaraviao/Projects/MauiSample/Platforms/iOS/Program.cs:line 13
cat0363 commented 1 year ago

This issue seems to occur when binding a string longer than the length specified in MaxLength of Entry, Editor to TextProperty.

The startPosition and endPosition obtained in the SetTextRange method of the TextInputExtions class were null. You should put a null check before calling GetTextRange method or consider MaxLength when calling GetPosition method.

Below is the source code of .NET MAUI side.

[src\Core\src\Platform\iOS\TextInputExtensions.cs]

internal static void SetTextRange(this IUITextInput platformView, int start, int selectedTextLength)
{
    int end = start + selectedTextLength;

    // Let's be sure we have positive positions
    start = Math.Max(start, 0);
    end = Math.Max(end, 0);

    // Switch start and end positions if necessary
    start = Math.Min(start, end);
    end = Math.Max(start, end);

    var startPosition = platformView.GetPosition(platformView.BeginningOfDocument, start);
    var endPosition = platformView.GetPosition(platformView.BeginningOfDocument, end);
    platformView.SelectedTextRange = platformView.GetTextRange(startPosition, endPosition);
}

If it is only a null check, it can be solved as follows.

[src\Core\src\Platform\iOS\TextInputExtensions.cs]

internal static void SetTextRange(this IUITextInput platformView, int start, int selectedTextLength)
{
    int end = start + selectedTextLength;

    // Let's be sure we have positive positions
    start = Math.Max(start, 0);
    end = Math.Max(end, 0);

    // Switch start and end positions if necessary
    start = Math.Min(start, end);
    end = Math.Max(start, end);

    var startPosition = platformView.GetPosition(platformView.BeginningOfDocument, start);
    var endPosition = platformView.GetPosition(platformView.BeginningOfDocument, end);
    if (startPosition is not null && endPosition is not null)
    {
        platformView.SelectedTextRange = platformView.GetTextRange(startPosition, endPosition);
    }
}
cat0363 commented 1 year ago

Or if you consider MaxLength,

[src\Core\src\Platform\iOS\TextInputExtensions.cs]

internal static void SetTextRange(this IUITextInput platformView, int start, int selectedTextLength, int maxLength)
{
    int end = start + selectedTextLength;

    // Let's be sure we have positive positions
    start = Math.Max(start, 0);
    end = Math.Max(end, 0);

    // Switch start and end positions if necessary
    start = Math.Min(start, end);
    end = Math.Max(start, end);

    if (maxLength >= 0)
    {
        start = Math.Min(start, maxLength);
        end = Math.Min(end, maxLength);
    }

    var startPosition = platformView.GetPosition(platformView.BeginningOfDocument, start);
    var endPosition = platformView.GetPosition(platformView.BeginningOfDocument, end);
    platformView.SelectedTextRange = platformView.GetTextRange(startPosition, endPosition);
}

[src\Controls\src\Core\Platform\iOS\Extensions\TextExtensions.cs]

public static void UpdateText(this UITextView textView, InputView inputView)
{
    // Setting the text causes the cursor to be reset to the end of the UITextView.
    // So, let's set back the cursor to the last known position and calculate a new
    // position if needed when the text was modified by a Converter.
    var oldText = textView.Text ?? string.Empty;
    var newText = TextTransformUtilites.GetTransformedText(
        inputView?.Text,
        textView.SecureTextEntry ? TextTransform.Default : inputView.TextTransform
    );

    // Re-calculate the cursor offset position if the text was modified by a Converter.
    // but if the text is being set by code, let's just move the cursor to the end.
    var cursorOffset = newText.Length - oldText.Length;
    var cursorPosition = textView.IsFirstResponder ? textView.GetCursorPosition(cursorOffset) : newText.Length;

    if (oldText != newText)
        textView.Text = newText;

    textView.SetTextRange(cursorPosition, 0, inputView.MaxLength);
}

public static void UpdateText(this UITextField textField, InputView inputView)
{
    // Setting the text causes the cursor to be reset to the end of the UITextView.
    // So, let's set back the cursor to the last known position and calculate a new
    // position if needed when the text was modified by a Converter.
    var oldText = textField.Text ?? string.Empty;
    var newText = TextTransformUtilites.GetTransformedText(
        inputView?.Text,
        textField.SecureTextEntry ? TextTransform.Default : inputView.TextTransform
    );

    // Re-calculate the cursor offset position if the text was modified by a Converter.
    // but if the text is being set by code, let's just move the cursor to the end.
    var cursorOffset = newText.Length - oldText.Length;
    var cursorPosition = textField.IsEditing ? textField.GetCursorPosition(cursorOffset) : newText.Length;

    if (oldText != newText)
        textField.Text = newText;

    textField.SetTextRange(cursorPosition, 0, inputView.MaxLength);
}
cat0363 commented 1 year ago

Additional Information: This issue also occurs on Android. Below is the exception information.

[HostConnection] HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_vulkan ANDROID_EMU_deferred_vulkan_commands ANDROID_EMU_vulkan_null_optional_strings ANDROID_EMU_vulkan_create_resources_with_requirements ANDROID_EMU_YUV_Cache ANDROID_EMU_vulkan_ignored_handles ANDROID_EMU_has_shared_slots_host_memory_allocator ANDROID_EMU_vulkan_free_memory_sync ANDROID_EMU_vulkan_shader_float16_int8 ANDROID_EMU_vulkan_async_queue_submit ANDROID_EMU_sync_buffer_data ANDROID_EMU_read_color_buffer_dma GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_gles_max_version_2 Java.Lang.IndexOutOfBoundsException: 'setSpan (11 ... 11) ends beyond length 10'

Java.Lang.IndexOutOfBoundsException: 'setSpan (11 ... 11) ends beyond length 10'

[mono-rt] [ERROR] FATAL UNHANDLED EXCEPTION: Java.Lang.IndexOutOfBoundsException: setSpan (11 ... 11) ends beyond length 10 [mono-rt] at Java.Interop.JniEnvironment.InstanceMethods.CallNonvirtualVoidMethod(JniObjectReference instance, JniObjectReference type, JniMethodInfo method, JniArgumentValue args) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/obj/Release/net7.0/JniEnvironment.g.cs:line 12324 [mono-rt] at Java.Interop.JniPeerMembers.JniInstanceMethods.InvokeVirtualVoidMethod(String encodedMember, IJavaPeerable self, JniArgumentValue parameters) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods_Invoke.cs:line 75 [mono-rt] at Android.Widget.EditText.SetSelection(Int32 index) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/net7.0/android-33/mcw/Android.Widget.EditText.cs:line 208 [mono-rt] at Microsoft.Maui.Controls.Platform.EditTextExtensions.UpdateText(EditText editText, InputView inputView) in C:\dotnet-maui-work\src\Controls\src\Core\Platform\Android\Extensions\EditTextExtensions.cs:line 46 [mono-rt] at Microsoft.Maui.Controls.Editor.MapText(IEditorHandler handler, Editor editor) in C:\dotnet-maui-work\src\Controls\src\Core\Editor\Editor.Android.cs:line 21 [mono-rt] at Microsoft.Maui.Controls.Editor.MapText(EditorHandler handler, Editor editor) in C:\dotnet-maui-work\src\Controls\src\Core\Editor\Editor.Android.cs:line 16 [mono-rt] at Microsoft.Maui.PropertyMapper2.<>c__DisplayClass5_0[[Microsoft.Maui.Controls.Editor, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Handlers.EditorHandler, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<Add>b__0(IElementHandler h, IElement v) in C:\dotnet-maui-work\src\Core\src\PropertyMapper.cs:line 172 [mono-rt] at Microsoft.Maui.PropertyMapper.UpdatePropertyCore(String key, IElementHandler viewHandler, IElement virtualView) in C:\dotnet-maui-work\src\Core\src\PropertyMapper.cs:line 47 [mono-rt] at Microsoft.Maui.PropertyMapper.UpdateProperties(IElementHandler viewHandler, IElement virtualView) in C:\dotnet-maui-work\src\Core\src\PropertyMapper.cs:line 82 [mono-rt] at Microsoft.Maui.Handlers.ElementHandler.SetVirtualView(IElement view) in C:\dotnet-maui-work\src\Core\src\Handlers\Element\ElementHandler.cs:line 79 [mono-rt] at Microsoft.Maui.Handlers.ViewHandler2[[Microsoft.Maui.IEditor, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[AndroidX.AppCompat.Widget.AppCompatEditText, Xamarin.AndroidX.AppCompat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IView view) in C:\dotnet-maui-work\src\Core\src\Handlers\View\ViewHandlerOfT.cs:line 53 [mono-rt] at Microsoft.Maui.Handlers.EditorHandler.SetVirtualView(IView view) in C:\dotnet-maui-work\src\Core\src\Handlers\Editor\EditorHandler.Android.cs:line 34 [mono-rt] at Microsoft.Maui.Handlers.ViewHandler2[[Microsoft.Maui.IEditor, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[AndroidX.AppCompat.Widget.AppCompatEditText, Xamarin.AndroidX.AppCompat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view) in C:\dotnet-maui-work\src\Core\src\Handlers\View\ViewHandlerOfT.cs:line 56 [mono-rt] at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler) in C:\dotnet-maui-work\src\Controls\src\Core\Element\Element.cs:line 831 [mono-rt] at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value) in C:\dotnet-maui-work\src\Controls\src\Core\Element\Element.cs:line 781 [mono-rt] at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value) in C:\dotnet-maui-work\src\Controls\src\Core\VisualElement\VisualElement.cs:line 1660 [mono-rt] at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context) in C:\dotnet-maui-work\src\Core\src\Platform\ElementExtensions.cs:line 96 [mono-rt] at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context) in C:\dotnet-maui-work\src\Core\src\Platform\ElementExtensions.cs:line 127 [mono-rt] at Microsoft.Maui.Handlers.LayoutHandler.SetVirtualView(IView view) in C:\dotnet-maui-work\src\Core\src\Handlers\Layout\LayoutHandler.Android.cs:line 43 [mono-rt] at Microsoft.Maui.Handlers.ViewHandler2[[Microsoft.Maui.ILayout, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.LayoutViewGroup, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view) in C:\dotnet-maui-work\src\Core\src\Handlers\View\ViewHandlerOfT.cs:line 56 [mono-rt] at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler) in C:\dotnet-maui-work\src\Controls\src\Core\Element\Element.cs:line 831 [mono-rt] at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value) in C:\dotnet-maui-work\src\Controls\src\Core\Element\Element.cs:line 781 [mono-rt] at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value) in C:\dotnet-maui-work\src\Controls\src\Core\VisualElement\VisualElement.cs:line 1660 [mono-rt] at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context) in C:\dotnet-maui-work\src\Core\src\Platform\ElementExtensions.cs:line 96 [mono-rt] at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context) in C:\dotnet-maui-work\src\Core\src\Platform\ElementExtensions.cs:line 127 [mono-rt] at Microsoft.Maui.Handlers.LayoutHandler.SetVirtualView(IView view) in C:\dotnet-maui-work\src\Core\src\Handlers\Layout\LayoutHandler.Android.cs:line 43 [mono-rt] at Microsoft.Maui.Handlers.ViewHandler2[[Microsoft.Maui.ILayout, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.LayoutViewGroup, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view) in C:\dotnet-maui-work\src\Core\src\Handlers\View\ViewHandlerOfT.cs:line 56 [mono-rt] at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler) in C:\dotnet-maui-work\src\Controls\src\Core\Element\Element.cs:line 831 [mono-rt] at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value) in C:\dotnet-maui-work\src\Controls\src\Core\Element\Element.cs:line 781 [mono-rt] at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value) in C:\dotnet-maui-work\src\Controls\src\Core\VisualElement\VisualElement.cs:line 1660 [mono-rt] at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context) in C:\dotnet-maui-work\src\Core\src\Platform\ElementExtensions.cs:line 96 [mono-rt] at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context) in C:\dotnet-maui-work\src\Core\src\Platform\ElementExtensions.cs:line 127 [mono-rt] at Microsoft.Maui.Handlers.LayoutHandler.SetVirtualView(IView view) in C:\dotnet-maui-work\src\Core\src\Handlers\Layout\LayoutHandler.Android.cs:line 43 [mono-rt] at Microsoft.Maui.Handlers.ViewHandler2[[Microsoft.Maui.ILayout, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.LayoutViewGroup, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view) in C:\dotnet-maui-work\src\Core\src\Handlers\View\ViewHandlerOfT.cs:line 56 [mono-rt] at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler) in C:\dotnet-maui-work\src\Controls\src\Core\Element\Element.cs:line 831 [mono-rt] at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value) in C:\dotnet-maui-work\src\Controls\src\Core\Element\Element.cs:line 781 [mono-rt] at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value) in C:\dotnet-maui-work\src\Controls\src\Core\VisualElement\VisualElement.cs:line 1660 [mono-rt] at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context) in C:\dotnet-maui-work\src\Core\src\Platform\ElementExtensions.cs:line 96 [mono-rt] at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context) in C:\dotnet-maui-work\src\Core\src\Platform\ElementExtensions.cs:line 127 [mono-rt] at Microsoft.Maui.Handlers.ScrollViewHandler.UpdateInsetView(IScrollView scrollView, IScrollViewHandler handler) in C:\dotnet-maui-work\src\Core\src\Handlers\ScrollView\ScrollViewHandler.Android.cs:line 175 [mono-rt] at Microsoft.Maui.Handlers.ScrollViewHandler.MapContent(IScrollViewHandler handler, IScrollView scrollView) in C:\dotnet-maui-work\src\Core\src\Handlers\ScrollView\ScrollViewHandler.Android.cs:line 109 [mono-rt] at Microsoft.Maui.PropertyMapper2.<>c__DisplayClass5_0[[Microsoft.Maui.IScrollView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Handlers.IScrollViewHandler, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<Add>b__0(IElementHandler h, IElement v) in C:\dotnet-maui-work\src\Core\src\PropertyMapper.cs:line 172 [mono-rt] at Microsoft.Maui.PropertyMapper.UpdatePropertyCore(String key, IElementHandler viewHandler, IElement virtualView) in C:\dotnet-maui-work\src\Core\src\PropertyMapper.cs:line 47 [mono-rt] at Microsoft.Maui.PropertyMapper.UpdateProperties(IElementHandler viewHandler, IElement virtualView) in C:\dotnet-maui-work\src\Core\src\PropertyMapper.cs:line 82 [mono-rt] at Microsoft.Maui.Handlers.ElementHandler.SetVirtualView(IElement view) in C:\dotnet-maui-work\src\Core\src\Handlers\Element\ElementHandler.cs:line 79 [mono-rt] at Microsoft.Maui.Handlers.ViewHandler2[[Microsoft.Maui.IScrollView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.MauiScrollView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IView view) in C:\dotnet-maui-work\src\Core\src\Handlers\View\ViewHandlerOfT.cs:line 53 [mono-rt] at Microsoft.Maui.Handlers.ViewHandler2[[Microsoft.Maui.IScrollView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.MauiScrollView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view) in C:\dotnet-maui-work\src\Core\src\Handlers\View\ViewHandlerOfT.cs:line 56 [mono-rt] at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler) in C:\dotnet-maui-work\src\Controls\src\Core\Element\Element.cs:line 831 [mono-rt] at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value) in C:\dotnet-maui-work\src\Controls\src\Core\Element\Element.cs:line 781 [mono-rt] at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value) in C:\dotnet-maui-work\src\Controls\src\Core\VisualElement\VisualElement.cs:line 1660 [mono-rt] at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context) in C:\dotnet-maui-work\src\Core\src\Platform\ElementExtensions.cs:line 96 [mono-rt] at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context) in C:\dotnet-maui-work\src\Core\src\Platform\ElementExtensions.cs:line 127 [mono-rt] at Microsoft.Maui.Handlers.ContentViewHandler.UpdateContent(IContentViewHandler handler) in C:\dotnet-maui-work\src\Core\src\Handlers\ContentView\ContentViewHandler.Android.cs:line 44 [mono-rt] at Microsoft.Maui.Handlers.ContentViewHandler.MapContent(IContentViewHandler handler, IContentView page) in C:\dotnet-maui-work\src\Core\src\Handlers\ContentView\ContentViewHandler.Android.cs:line 49 [mono-rt] at Microsoft.Maui.PropertyMapper2.<>cDisplayClass5_0[[Microsoft.Maui.IContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Handlers.IContentViewHandler, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].b__0(IElementHandler h, IElement v) in C:\dotnet-maui-work\src\Core\src\PropertyMapper.cs:line 172 [mono-rt] at Microsoft.Maui.PropertyMapper.UpdatePropertyCore(String key, IElementHandler viewHandler, IElement virtualView) in C:\dotnet-maui-work\src\Core\src\PropertyMapper.cs:line 47 [mono-rt] at Microsoft.Maui.PropertyMapper.UpdateProperties(IElementHandler viewHandler, IElement virtualView) in C:\dotnet-maui-work\src\Core\src\PropertyMapper.cs:line 82 [mono-rt] at Microsoft.Maui.Handlers.ElementHandler.SetVirtualView(IElement view) in C:\dotnet-maui-work\src\Core\src\Handlers\Element\ElementHandler.cs:line 79 [mono-rt] at Microsoft.Maui.Handlers.ViewHandler2[[Microsoft.Maui.IContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.ContentViewGroup, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IView view) in C:\dotnet-maui-work\src\Core\src\Handlers\View\ViewHandlerOfT.cs:line 53 [mono-rt] at Microsoft.Maui.Handlers.ContentViewHandler.SetVirtualView(IView view) in C:\dotnet-maui-work\src\Core\src\Handlers\ContentView\ContentViewHandler.Android.cs:line 27 [mono-rt] at Microsoft.Maui.Handlers.ViewHandler2[[Microsoft.Maui.IContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.ContentViewGroup, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view) in C:\dotnet-maui-work\src\Core\src\Handlers\View\ViewHandlerOfT.cs:line 56 [mono-rt] at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler) in C:\dotnet-maui-work\src\Controls\src\Core\Element\Element.cs:line 831 [mono-rt] at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value) in C:\dotnet-maui-work\src\Controls\src\Core\Element\Element.cs:line 781 [mono-rt] at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value) in C:\dotnet-maui-work\src\Controls\src\Core\VisualElement\VisualElement.cs:line 1660 [mono-rt] at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context) in C:\dotnet-maui-work\src\Core\src\Platform\ElementExtensions.cs:line 96 [mono-rt] at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context) in C:\dotnet-maui-work\src\Core\src\Platform\ElementExtensions.cs:line 127 [mono-rt] at Microsoft.Maui.Platform.MauiContextExtensions.ToPlatform(IView view, IMauiContext fragmentMauiContext, Context context, LayoutInflater layoutInflater, FragmentManager childFragmentManager) in C:\dotnet-maui-work\src\Core\src\Platform\Android\MauiContextExtensions.cs:line 96 [mono-rt] at Microsoft.Maui.Controls.Platform.Compatibility.ShellFragmentContainer.OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) in C:\dotnet-maui-work\src\Controls\src\Core\Compatibility\Handlers\Shell\Android\ShellFragmentContainer.cs:line 26 [mono-rt] at AndroidX.Fragment.App.Fragment.n_OnCreateView_Landroid_view_LayoutInflater_Landroid_view_ViewGroup_Landroid_osBundle(IntPtr jnienv, IntPtr nativethis, IntPtr native_inflater, IntPtr native_container, IntPtr native_savedInstanceState) in C:\a_work\1\s\generated\androidx.fragment.fragment\obj\Release et6.0-android\generated\src\AndroidX.Fragment.App.Fragment.cs:line 2031 [mono-rt] at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPLLL_L(_JniMarshal_PPLLL_L callback, IntPtr jnienv, IntPtr klazz, IntPtr p0, IntPtr p1, IntPtr p2) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:line 352 [mono-rt] --- End of managed Java.Lang.IndexOutOfBoundsException stack trace --- [mono-rt] java.lang.IndexOutOfBoundsException: setSpan (11 ... 11) ends beyond length 10 [mono-rt] at android.text.SpannableStringBuilder.checkRange(SpannableStringBuilder.java:1325) [mono-rt] at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:684) [mono-rt] at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:676) [mono-rt] at androidx.emoji2.text.SpannableBuilder.setSpan(SpannableBuilder.java:140) [mono-rt] at android.text.Selection.setSelection(Selection.java:94) [mono-rt] at android.text.Selection.setSelection(Selection.java:78) [mono-rt] at android.text.Selection.setSelection(Selection.java:153) [mono-rt] at android.widget.EditText.setSelection(EditText.java:135) [mono-rt] at crc640ec207abc449b2ca.ShellFragmentContainer.n_onCreateView(Native Method) [mono-rt] at crc640ec207abc449b2ca.ShellFragmentContainer.onCreateView(ShellFragmentContainer.java:41) [mono-rt] at androidx.fragment.app.Fragment.performCreateView(Fragment.java:3113) [mono-rt] at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:524) [mono-rt] at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:261) [mono-rt] at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1901) [mono-rt] at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1819) [mono-rt] at androidx.fragment.app.FragmentManager.execSingleAction(FragmentManager.java:1731) [mono-rt] at androidx.fragment.app.BackStackRecord.commitNow(BackStackRecord.java:317) [mono-rt] at androidx.viewpager2.adapter.FragmentStateAdapter.placeFragmentInViewHolder(FragmentStateAdapter.java:341) [mono-rt] at androidx.viewpager2.adapter.FragmentStateAdapter.onViewAttachedToWindow(FragmentStateAdapter.java:276) [mono-rt] at androidx.viewpager2.adapter.FragmentStateAdapter.onViewAttachedToWindow(FragmentStateAdapter.java:67) [mono-rt] at androidx.recyclerview.widget.RecyclerView.dispatchChildAttached(RecyclerView.java:8291) [mono-rt] at androidx.recyclerview.widget.RecyclerView$5.addView(RecyclerView.java:924) [mono-rt] at androidx.recyclerview.widget.ChildHelper.addView(ChildHelper.java:107) [mono-rt] at androidx.recyclerview.widget.RecyclerView$LayoutManager.addViewInt(RecyclerView.java:9344) [mono-rt] at androidx.recyclerview.widget.RecyclerView$LayoutManager.addView(RecyclerView.java:9302) [mono-rt] at androidx.recyclerview.widget.RecyclerView$LayoutManager.addView(RecyclerView.java:9289) [mono-rt] at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1676) [mono-rt] at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1622) [mono-rt] at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:687) [mono-rt] at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:4604) [mono-rt] at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:4307) [mono-rt] at androidx.recyclerview.widget.RecyclerView.onLayout(RecyclerView.java:4873) [mono-rt] at android.view.View.layout(View.java:22844) [mono-rt] at android.view.ViewGroup.layout(ViewGroup.java:6389) [mono-rt] at androidx.viewpager2.widget.ViewPager2.onLayout(ViewPager2.java:527) [mono-rt] at android.view.View.layout(View.java:22844) [mono-rt] at android.view.ViewGroup.layout(ViewGroup.java:6389) [mono-rt] at com.google.android.material.appbar.HeaderScrollingViewBehavior.layoutChild(HeaderScrollingViewBehavior.java:149) [mono-rt] at com.google.android.material.appbar.ViewOffsetBehavior.onLayoutChild(ViewOffsetBehavior.java:43) [mono-rt] at com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior.onLayoutChild(AppBarLayout.java:2376) [mono-rt] at androidx.coordinatorlayout.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:953) [mono-rt] at android.view.View.layout(View.java:22844) [mono-rt] at android.view.ViewGroup.layout(ViewGroup.java:6389) [mono-rt] at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332) [mono-rt] at android.widget.FrameLayout.onLayout(FrameLayout.java:270) [mono-rt] at android.view.View.layout(View.java:22844) [mono-rt] at android.view.ViewGroup.layout(ViewGroup.java:6389) [mono-rt] at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1829) [mono-rt] at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1673) [mono-rt] at android.widget.LinearLayout.onLayout(LinearLayout.java:1582) [mono-rt] at android.view.View.layout(View.java:22844) [mono-rt] at android.view.ViewGroup.layout(ViewGroup.java:6389) [mono-rt] at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332) [mono-rt] at android.widget.FrameLayout.onLayout(FrameLayout.java:270) [mono-rt] at android.view.View.layout(View.java:22844) [mono-rt] at android.view.ViewGroup.layout(ViewGroup.java:6389) [mono-rt] at androidx.drawerlayout.widget.DrawerLayout.onLayout(DrawerLayout.java:1273) [mono-rt] at android.view.View.layout(View.java:22844) [mono-rt] at android.view.ViewGroup.layout(ViewGroup.java:6389) [mono-rt] at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1829) [mono-rt] at android.widget.LinearLayout.layoutHorizontal(LinearLayout.java:1818) [mono-rt] at android.widget.LinearLayout.onLayout(LinearLayout.java:1584) [mono-rt] at android.view.View.layout(View.java:22844) [mono-rt] at android.view.ViewGroup.layout(ViewGroup.java:6389) [mono-rt] at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332) [mono-rt] at android.widget.FrameLayout.onLayout(FrameLayout.java:270) [mono-rt] at android.view.View.layout(View.java:22844) [mono-rt] at android.view.ViewGroup.layout(ViewGroup.java:6389) [mono-rt] at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332) [mono-rt] at android.widget.FrameLayout.onLayout(FrameLayout.java:270) [mono-rt] at android.view.View.layout(View.java:22844) [mono-rt] at android.view.ViewGroup.layout(ViewGroup.java:6389) [mono-rt] at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332) [mono-rt] at android.widget.FrameLayout.onLayout(FrameLayout.java:270) [mono-rt] at android.view.View.layout(View.java:22844) [mono-rt] at android.view.ViewGroup.layout(ViewGroup.java:6389) [mono-rt] at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1829) [mono-rt] at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1673) [mono-rt] at android.widget.LinearLayout.onLayout(LinearLayout.java:1582) [mono-rt] at android.view.View.layout(View.java:22844) [mono-rt] at android.view.ViewGroup.layout(ViewGroup.java:6389) [mono-rt] at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332) [mono-rt] at android.widget.FrameLayout.onLayout(FrameLayout.java:270) [mono-rt] at com.android.internal.policy.DecorView.onLayout(DecorView.java:784) [mono-rt] at android.view.View.layout(View.java:22844) [mono-rt] at android.view.ViewGroup.layout(ViewGroup.java:6389) [mono-rt] at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:3470) [mono-rt] at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2938) [mono-rt] at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1952) [mono-rt] at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8171) [mono-rt] at android.view.Choreographer$CallbackRecord.run(Choreographer.java:972) [mono-rt] at android.view.Choreographer.doCallbacks(Choreographer.java:796) [mono-rt] at android.view.Choreographer.doFrame(Choreographer.java:731) [mono-rt] at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:957) [mono-rt] at android.os.Handler.handleCallback(Handler.java:938) [mono-rt] at android.os.Handler.dispatchMessage(Handler.java:99) [mono-rt] at android.os.Looper.loop(Looper.java:223) [mono-rt] at android.app.ActivityThread.main(ActivityThread.java:7656) [mono-rt] at java.lang.reflect.Method.invoke(Native Method) [mono-rt] at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) [mono-rt] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) [mono-rt] [mono-rt] --- End of managed Java.Lang.IndexOutOfBoundsException stack trace --- [mono-rt] java.lang.IndexOutOfBoundsException: setSpan (11 ... 11) ends beyond length 10 [mono-rt] at android.text.SpannableStringBuilder.checkRange(SpannableStringBuilder.java:1325) [mono-rt] at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:684) [mono-rt] at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:676) [mono-rt] at androidx.emoji2.text.SpannableBuilder.setSpan(SpannableBuilder.java:140) [mono-rt] at android.text.Selection.setSelection(Selection.java:94) [mono-rt] at android.text.Selection.setSelection(Selection.java:78) [mono-rt] at android.text.Selection.setSelection(Selection.java:153) [mono-rt] at android.widget.EditText.setSelection(EditText.java:135) [mono-rt] at crc640ec207abc449b2ca.ShellFragmentContainer.n_onCreateView(Native Method) [mono-rt] at crc640ec207abc449b2ca.ShellFragmentContainer.onCreateView(ShellFragmentContainer.java:41) [mono-rt] at androidx.fragment.app.Fragment.performCreateView(Fragment.java:3113) [mono-rt] at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:524) [mono-rt] at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:261) [mono-rt] at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1901) [mono-rt] at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1819) [mono-rt] at androidx.fragment.app.FragmentManager.execSingleAction(FragmentManager.java:1731) [mono-rt] at androidx.fragment.app.BackStackRecord.commitNow(BackStackRecord.java:317) [mono-rt] at androidx.viewpager2.adapter.FragmentStateAdapter.placeFragmentInViewHolder(FragmentStateAdapter.java:341) [mono-rt] at androidx.viewpager2.adapter.FragmentStateAdapter.onViewAttachedToWindow(FragmentStateAdapter.java:276) [mono-rt] at androidx.viewpager2.adapter.FragmentStateAdapter.onViewAttachedToWindow(FragmentStateAdapter.java:67) [mono-rt] at androidx.recyclerview.widget.RecyclerView.dispatchChildAttached(RecyclerView.java:8291) [mono-rt] at androidx.recyclerview.widget.RecyclerView$5.addView(RecyclerView.java:924) [mono-rt] at androidx.recyclerview.widget.ChildHelper.addView(ChildHelper.java:107) [mono-rt] at androidx.recyclerview.widget.RecyclerView$LayoutManager.addViewInt(RecyclerView.java:9344) [mono-rt] at androidx.recyclerview.widget.RecyclerView$LayoutManager.addView(RecyclerView.java:9302) [mono-rt] at androidx.recyclerview.widget.RecyclerView$LayoutManager.addView(RecyclerView.java:9289) [mono-rt] at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1676) [mono-rt] at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1622) [mono-rt] at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:687) [mono-rt] at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:4604) [mono-rt] at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:4307) [mono-rt] at androidx.recyclerview.widget.RecyclerView.onLayout(RecyclerView.java:4873) [mono-rt] at android.view.View.layout(View.java:22844) [mono-rt] at android.view.ViewGroup.layout(ViewGroup.java:6389) [mono-rt] at androidx.viewpager2.widget.ViewPager2.onLayout(ViewPager2.java:527) [mono-rt] at android.view.View.layout(View.java:22844) [mono-rt] at android.view.ViewGroup.layout(ViewGroup.java:6389) [mono-rt] at com.google.android.material.appbar.HeaderScrollingViewBehavior.layoutChild(HeaderScrollingViewBehavior.java:149) [mono-rt] at com.google.android.material.appbar.ViewOffsetBehavior.onLayoutChild(ViewOffsetBehavior.java:43) [mono-rt] at com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior.onLayoutChild(AppBarLayout.java:2376) [mono-rt] at androidx.coordinatorlayout.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:953) [mono-rt] at android.view.View.layout(View.java:22844) [mono-rt] at android.view.ViewGroup.layout(ViewGroup.java:6389) [mono-rt] at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332) [mono-rt] at android.widget.FrameLayout.onLayout(FrameLayout.java:270) [mono-rt] at android.view.View.layout(View.java:22844) [mono-rt] at android.view.ViewGroup.layout(ViewGroup.java:6389) [mono-rt] at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1829) [mono-rt] at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1673) [mono-rt] at android.widget.LinearLayout.onLayout(LinearLayout.java:1582) [mono-rt] at android.view.View.layout(View.java:22844) [mono-rt] at android.view.ViewGroup.layout(ViewGroup.java:6389) [mono-rt] at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332) [mono-rt] at android.widget.FrameLayout.onLayout(FrameLayout.java:270) [mono-rt] at android.view.View.layout(View.java:22844) [mono-rt] at android.view.ViewGroup.layout(ViewGroup.java:6389) [mono-rt] at androidx.drawerlayout.widget.DrawerLayout.onLayout(DrawerLayout.java:1273) [mono-rt] at android.view.View.layout(View.java:22844) [mono-rt] at android.view.ViewGroup.layout(ViewGroup.java:6389) [mono-rt] at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1829) [mono-rt] at android.widget.LinearLayout.layoutHorizontal(LinearLayout.java:1818) [mono-rt] at android.widget.LinearLayout.onLayout(LinearLayout.java:1584) [mono-rt] at android.view.View.layout(View.java:22844) [mono-rt] at android.view.ViewGroup.layout(ViewGroup.java:6389) [mono-rt] at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332) [mono-rt] at android.widget.FrameLayout.onLayout(FrameLayout.java:270) [mono-rt] at android.view.View.layout(View.java:22844) [mono-rt] at android.view.ViewGroup.layout(ViewGroup.java:6389) [mono-rt] at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332) [mono-rt] at android.widget.FrameLayout.onLayout(FrameLayout.java:270) [mono-rt] at android.view.View.layout(View.java:22844) [mono-rt] at android.view.ViewGroup.layout(ViewGroup.java:6389) [mono-rt] at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332) [mono-rt] at android.widget.FrameLayout.onLayout(FrameLayout.java:270) [mono-rt] at android.view.View.layout(View.java:22844) [mono-rt] at android.view.ViewGroup.layout(ViewGroup.java:6389) [mono-rt] at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1829) [mono-rt] at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1673) [mono-rt] at android.widget.LinearLayout.onLayout(LinearLayout.java:1582) [mono-rt] at android.view.View.layout(View.java:22844) [mono-rt] at android.view.ViewGroup.layout(ViewGroup.java:6389) [mono-rt] at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332) [mono-rt] at android.widget.FrameLayout.onLayout(FrameLayout.java:270) [mono-rt] at com.android.internal.policy.DecorView.onLayout(DecorView.java:784) [mono-rt] at android.view.View.layout(View.java:22844) [mono-rt] at android.view.ViewGroup.layout(ViewGroup.java:6389) [mono-rt] at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:3470) [mono-rt] at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2938) [mono-rt] at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1952) [mono-rt] at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8171) [mono-rt] at android.view.Choreographer$CallbackRecord.run(Choreographer.java:972) [mono-rt] at android.view.Choreographer.doCallbacks(Choreographer.java:796) [mono-rt] at android.view.Choreographer.doFrame(Choreographer.java:731) [mono-rt] at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:957) [mono-rt] at android.os.Handler.handleCallback(Handler.java:938) [mono-rt] at android.os.Handler.dispatchMessage(Handler.java:99) [mono-rt] at android.os.Looper.loop(Looper.java:223) [mono-rt] at android.app.ActivityThread.main(ActivityThread.java:7656) [mono-rt] at java.lang.reflect.Method.invoke(Native Method) [mono-rt] at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) [mono-rt] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) [mono-rt] [HostConnection] HostConnection::get() New Host Connection established 0xe8f7b420, tid 17742 [HostConnection] HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_vulkan ANDROID_EMU_deferred_vulkan_commands ANDROID_EMU_vulkan_null_optional_strings ANDROID_EMU_vulkan_create_resources_with_requirements ANDROID_EMU_YUV_Cache ANDROID_EMU_vulkan_ignored_handles ANDROID_EMU_has_shared_slots_host_memory_allocator ANDROID_EMU_vulkan_free_memory_sync ANDROID_EMU_vulkan_shader_float16_int8 ANDROID_EMU_vulkan_async_queue_submit ANDROID_EMU_sync_buffer_data ANDROID_EMU_read_color_buffer_dma GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_gles_max_version_2

cat0363 commented 1 year ago

On the Android side, an IndexOutOfBoundsException occurred when calling the SetSelection method in the UpdateText method of the EditTextExtensions class.

[src\Controls\src\Core\Platform\Android\Extensions\EditTextExtensions.cs]

public static void UpdateText(this EditText editText, InputView inputView)
{
    (var oldText, var newText) = GetTexts(editText, inputView);

    if (oldText != newText)
    {
        editText.Text = newText;

        // When updating from xplat->plat, we set the selection (cursor) to the end of the text
        editText.SetSelection(newText.Length);
    }
}

If you consider the MaxLength property of Entry, Editor,

[src\Controls\src\Core\Platform\Android\Extensions\EditTextExtensions.cs]

public static void UpdateText(this EditText editText, InputView inputView)
{
    (var oldText, var newText) = GetTexts(editText, inputView);

    if (oldText != newText)
    {
        editText.Text = newText;

        // When updating from xplat->plat, we set the selection (cursor) to the end of the text
        int selectionLength = newText.Length;
        if (inputView.MaxLength >= 0)
        {
            selectionLength = Math.Min(selectionLength, inputView.MaxLength);
        }
        editText.SetSelection(selectionLength);
    }
}
cat0363 commented 1 year ago

Exceptions don't occur on Windows, but if you want to do the same, it would look like this:

[src\Controls\src\Core\Platform\Windows\Extensions\TextBoxExtensions.cs]

public static void UpdateText(this TextBox platformControl, InputView inputView)
{
    var hasFocus = platformControl.FocusState != UI.Xaml.FocusState.Unfocused;
    var passwordBox = platformControl as MauiPasswordTextBox;
    var isPassword = passwordBox?.IsPassword ?? false;
    var textTransform = inputView?.TextTransform ?? TextTransform.None;

    // Setting the text causes the cursor to be reset to position zero.
    // So, let's retain the current cursor position and calculate a new cursor
    // position if the text was modified by a Converter.
    var oldText = platformControl.Text ?? string.Empty;
    var newText = TextTransformUtilites.GetTransformedText(
        inputView?.Text,
        isPassword ? TextTransform.None : textTransform
    );

    // Re-calculate the cursor offset position if the text was modified by a Converter.
    // but if the text is being set by code, let's just move the cursor to the end.
    var cursorOffset = newText.Length - oldText.Length;
    int cursorPosition = hasFocus ? platformControl.GetCursorPosition(cursorOffset) : newText.Length;

    if (inputView?.MaxLength >= 0)
    {
        cursorPosition = Math.Min(cursorPosition, inputView.MaxLength);
    }

    if (oldText != newText && passwordBox is not null)
        passwordBox.Password = newText;
    else if (oldText != newText)
        platformControl.Text = newText;

    platformControl.Select(cursorPosition, 0);
}

However, there is no problem with the Windows TextBox Select method even if you specify an Index that exceeds MaxLength, so there is no problem even if you do not include a guard condition.

In addition to the solution in PR #7371, the MaxLength property should be considered.

juniorsaraviao commented 1 year ago

Hi, @cat0363, thanks for your responses. One question, I really need the MaxLength working on both platforms because I'll get the value from API and now it's breaking my app. When could these changes be merged? Or can I include this functionality using Handlers?

cat0363 commented 1 year ago

Hi, @juniorsaraviao The easiest workaround is to ensure that the string you bind does not exceed MaxLength until the problem is fixed. For example, cut the part exceeding MaxLength at the stage of setting the value in ViewModel. When re-implementing with Handler, it is recommended to check the source code below as it is the first caller that triggers this issue.

[src\Controls\src\Core\Editor\Editor.Android.cs] [src\Controls\src\Core\Entry\Entry.Android.cs] [src\Controls\src\Core\Editor\Editor.iOS.cs] [src\Controls\src\Core\Entry\Entry.iOS.cs] [src\Controls\src\Core\Editor\Editor.Windows.cs]

In that case, you'll probably have to reimplement the MapText part yourself, but you'll have to port everything you need. I can create a PR, but I don't know when it will be reviewed and merged.

duindain commented 1 year ago

We've just run into this error in our app on iOS devices only but I think its slightly different cause as we aren't exceeding MaxLength

We've added a custom handler to sanitize the text as we want the result to be visible to the user if there was a change however when setting the sanitized text back to the entry or editor we get this crash (The handler gets called a few times before the crash and successfully completes)

Ive added some code to check for exceeding the maxlength and we are nowhere near exceeding it, my current test is around 1600 characters in a 5000 character limit

This is the handler we've added after adding the maxlength check in as well

Microsoft.Maui.Handlers.EditorHandler.Mapper.AppendToMapping("FixEditorFocus", (handler, view) =>
            {
#if WINDOWS
                handler.PlatformView.TextChanged += (object sender, Microsoft.UI.Xaml.Controls.TextChangedEventArgs e) =>
#endif
#if ANDROID
                handler.PlatformView.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) =>
#endif
#if IOS
                handler.PlatformView.TextSetOrChanged += (object sender, EventArgs e) =>
#endif
                {
                    var clean = Regex.Replace(handler.PlatformView.Text, @"[^\u0009\u000A\u000D\u0020-\u007E]", string.Empty);
                    var maxLength = -1;
                    if (handler.VirtualView is Editor editor && editor.MaxLength > 0)
                    {
                        maxLength = editor.MaxLength;
                    }
                    if (handler.VirtualView is Entry entry && entry.MaxLength > 0)
                    {
                        maxLength = entry.MaxLength;
                    }
                    if (maxLength > 0 && clean.Length > maxLength)
                    {
                        clean = clean.Substring(0, maxLength);
                        Logger.WriteDebug($"Reduced cleaned string to {maxLength} to prevent crash after sanitized string");
                    }
                    if (clean != handler.PlatformView.Text)
                    {
                        handler.PlatformView.Text = clean;
                    }
                };
            });

The maxlength substring is not executing in the above as we aren't exceeding the maxlength

This is the error we are getting

Logger.WriteException: Value cannot be null. (Parameter 'fromPosition'), someuserid: id, error message:    at ObjCRuntime.ThrowHelper.ThrowArgumentNullException(String argumentName)
   at ObjCRuntime.NativeObjectExtensions.GetNonNullHandle(INativeObject self, String argumentName)
   at UIKit.UITextView.GetTextRange(UITextPosition fromPosition, UITextPosition toPosition)
   at Microsoft.Maui.Platform.TextInputExtensions.SetTextRange(IUITextInput platformView, Int32 start, Int32 selectedTextLength)
   at Microsoft.Maui.Controls.Platform.TextExtensions.UpdateText(UITextView textView, InputView inputView)
   at Microsoft.Maui.Controls.Editor.MapText(IEditorHandler handler, Editor editor)
   at Microsoft.Maui.Controls.Editor.MapText(EditorHandler handler, Editor editor)
   at Microsoft.Maui.PropertyMapper`2.<>c__DisplayClass5_0[[Microsoft.Maui.Controls.Editor, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Handlers.EditorHandler, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<Add>b__0(IElementHandler h, IElement v)
   at Microsoft.Maui.PropertyMapper.UpdatePropertyCore(String key, IElementHandler viewHandler, IElement virtualView)
   at Microsoft.Maui.PropertyMapper.UpdateProperty(IElementHandler viewHandler, IElement virtualView, String property)
   at Microsoft.Maui.Handlers.ElementHandler.UpdateValue(String property)
   at Microsoft.Maui.Controls.Element.OnPropertyChanged(String propertyName)
   at Microsoft.Maui.Controls.BindableObject.SetValueActual(BindableProperty property, BindablePropertyContext context, Object value, Boolean currentlyApplying, SetValueFlags attributes, Boolean silent)
   at Microsoft.Maui.Controls.BindableObject.SetValueCore(BindableProperty property, Object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes)
   at Microsoft.Maui.Controls.BindingExpression.ApplyCore(Object sourceObject, BindableObject target, BindableProperty property, Boolean fromTarget)
   at Microsoft.Maui.Controls.BindingExpression.Apply(Boolean fromTarget)
   at Microsoft.Maui.Controls.BindingExpression.BindingExpressionPart.<PropertyChanged>b__49_0()
   at Microsoft.Maui.Controls.DispatcherExtensions.DispatchIfRequired(IDispatcher dispatcher, Action action)
   at Microsoft.Maui.Controls.BindingExpression.BindingExpressionPart.PropertyChanged(Object sender, PropertyChangedEventArgs args)
   at Microsoft.Maui.Controls.BindingExpression.WeakPropertyChangedProxy.OnPropertyChanged(Object sender, PropertyChangedEventArgs e)
   at Namespace.anamespace.OurApp.Common.BindableBase.OnPropertyChanged(String propertyName) in /Users/me/Source/anamespace.OurApp/OurApp/OurApp.Common/Common/BindableBase.cs:line 81
   at Namespace.anamespace.OurApp.Common.BindableBase.SetProperty[String](String& storage, String value, String propertyName) in /Users/me/Source/anamespace.OurApp/OurApp/OurApp.Common/Common/BindableBase.cs:line 61
   at Namespace.anamespace.OurApp.Common.ViewModels.APage.AVM.set_SummaryText(String value) in /Users/me/Source/anamespace.OurApp/OurApp/OurApp.Common/ViewModels/APage/AVM.cs:line 41
   at Namespace.anamespace.OurApp.Common.ViewModels.APage.AVM.ReloadAssessmentSummary() in /Users/me/Source/anamespace.OurApp/OurApp/OurApp.Common/ViewModels/APage/AVM.cs:line 177
   at Namespace.anamespace.OurApp.Common.ViewModels.APage.AVM.OnAppearing() in /Users/me/Source/anamespace.OurApp/OurApp/OurApp.Common/ViewModels/APage/AVM.cs:line 160
   at Namespace.anamespace.OurApp.XForms.Pages.APage.CreateControlAsync(CancellationToken cancellationToken) in /Users/me/Source/anamespace.OurApp/OurApp/OurApp/Pages/Main/APagePage.xaml.cs:line 159
   at Namespace.anamespace.OurApp.XForms.Pages.APage.<OnBindingContextChanged>b__11_1(Object sender, PropertyChangedEventArgs e) in /Users/me/Source/anamespace.OurApp/OurApp/OurApp/Pages/Main/APagePage.xaml.cs:line 72
   at ObjCRuntime.Runtime.ThrowException(IntPtr gchandle)
   at UIKit.UIApplication.UIApplicationMain(Int32 argc, String[] argv, IntPtr principalClassName, IntPtr delegateClassName)
   at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass)
   at OurApp.Program.Main(String[] args) in /Users/me/Source/anamespace.OurApp/OurApp/OurApp/Platforms/iOS/Program.cs:line 15, unique instance id: URYBLZGE [line 243]
bnoffer commented 1 year ago

I ran into the same error, but the root cause was not the string length, but there were line breaks within the strings that was assigned.

I now added logic that removes \r and \n from the string and the app does not crash anymore.

jfversluis commented 1 year ago

The author of this PR to fix this has confirmed that this is no longer an issue. Please test with .NET 8 from next week and let us know if this has not been resolved for you. Thanks!

varyamereon commented 1 year ago

@jfversluis I am just now encountering this issue and I am using net8.0. I can't for the life of me figure out what's causing it, it's with a new page that I have added to my app. It has some entries, editors as well as other controls. Navigating to the page causes no issue, neither does navigating back and returning to a new instance of the page. However, if I edit the value of one Entry for example, then navigate back and to a new instance this exception is thrown. The stack trace is here:

System.ArgumentNullException: Value cannot be null. (Parameter 'fromPosition')
   at ObjCRuntime.ThrowHelper.ThrowArgumentNullException(String argumentName) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/ThrowHelper.cs:line 28
   at ObjCRuntime.NativeObjectExtensions.GetNonNullHandle(INativeObject self, String argumentName) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/INativeObject.cs:line 42
   at UIKit.UITextField.GetTextRange(UITextPosition fromPosition, UITextPosition toPosition) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/build/dotnet/ios/generated-sources/UIKit/UITextField.g.cs:line 648
   at Microsoft.Maui.Platform.TextInputExtensions.SetTextRange(IUITextInput platformView, Int32 start, Int32 selectedTextLength)
   at Microsoft.Maui.Controls.Platform.TextExtensions.UpdateText(IUITextInput textInput, InputView inputView, Boolean isEditing)
   at Microsoft.Maui.Controls.Platform.TextExtensions.UpdateText(UITextField textField, InputView inputView)
   at Microsoft.Maui.Controls.Entry.MapText(IEntryHandler handler, Entry entry)
   at Microsoft.Maui.PropertyMapperExtensions.<>c__DisplayClass2_0`2[[Microsoft.Maui.Controls.Entry, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Handlers.IEntryHandler, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<ReplaceMapping>b__0(IEntryHandler h, Entry v, Action`2 p)
   at Microsoft.Maui.PropertyMapperExtensions.<>c__DisplayClass1_0`2[[Microsoft.Maui.Controls.Entry, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Handlers.IEntryHandler, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<ModifyMapping>g__newMethod|0(IElementHandler handler, IElement view)
   at Microsoft.Maui.PropertyMapper`2.<>c__DisplayClass5_0[[Microsoft.Maui.IEntry, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Handlers.IEntryHandler, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<Add>b__0(IElementHandler h, IElement v)
   at Microsoft.Maui.PropertyMapper.UpdatePropertyCore(String key, IElementHandler viewHandler, IElement virtualView)
   at Microsoft.Maui.PropertyMapper.UpdateProperties(IElementHandler viewHandler, IElement virtualView)
   at Microsoft.Maui.Handlers.ElementHandler.SetVirtualView(IElement view)
   at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.IEntry, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.MauiTextField, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IView view)
   at Microsoft.Maui.Handlers.EntryHandler.SetVirtualView(IView view)
   at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.IEntry, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.MauiTextField, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view)
   at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler)
   at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value)
   at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value)
   at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context)
   at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context)
   at Microsoft.Maui.Handlers.LayoutHandler.SetVirtualView(IView view)
   at Syncfusion.Maui.Core.SfViewHandler.SetVirtualView(IView view)
   at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.ILayout, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.LayoutView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view)
   at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler)
   at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value)
   at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value)
   at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context)
   at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context)
   at Microsoft.Maui.Handlers.LayoutHandler.SetVirtualView(IView view)
   at Syncfusion.Maui.Core.SfViewHandler.SetVirtualView(IView view)
   at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.ILayout, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.LayoutView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view)
   at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler)
   at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value)
   at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value)
   at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context)
   at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context)
   at Microsoft.Maui.Handlers.LayoutHandler.SetVirtualView(IView view)
   at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.ILayout, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.LayoutView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view)
   at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler)
   at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value)
   at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value)
   at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context)
   at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context)
   at Microsoft.Maui.Handlers.LayoutHandler.SetVirtualView(IView view)
   at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.ILayout, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.LayoutView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view)
   at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler)
   at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value)
   at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value)
   at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context)
   at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context)
   at Microsoft.Maui.Handlers.BorderHandler.UpdateContent(IBorderHandler handler)
   at Microsoft.Maui.Handlers.BorderHandler.MapContent(IBorderHandler handler, IBorderView border)
   at Microsoft.Maui.PropertyMapper`2.<>c__DisplayClass5_0[[Microsoft.Maui.IBorderView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Handlers.IBorderHandler, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<Add>b__0(IElementHandler h, IElement v)
   at Microsoft.Maui.PropertyMapper.UpdatePropertyCore(String key, IElementHandler viewHandler, IElement virtualView)
   at Microsoft.Maui.PropertyMapper.UpdateProperties(IElementHandler viewHandler, IElement virtualView)
   at Microsoft.Maui.Handlers.ElementHandler.SetVirtualView(IElement view)
   at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.IBorderView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.ContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IView view)
   at Microsoft.Maui.Handlers.BorderHandler.SetVirtualView(IView view)
   at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.IBorderView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.ContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view)
   at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler)
   at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value)
   at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value)
   at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context)
   at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context)
   at Microsoft.Maui.Handlers.LayoutHandler.SetVirtualView(IView view)
   at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.ILayout, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.LayoutView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view)
   at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler)
   at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value)
   at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value)
   at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context)
   at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context)
   at Microsoft.Maui.Handlers.ScrollViewHandler.UpdateContentView(IScrollView scrollView, IScrollViewHandler handler, ICrossPlatformLayout crossPlatformLayout)
   at Microsoft.Maui.Handlers.ScrollViewHandler.MapContent(IScrollViewHandler handler, IScrollView scrollView)
   at Microsoft.Maui.PropertyMapper`2.<>c__DisplayClass5_0[[Microsoft.Maui.IScrollView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Handlers.IScrollViewHandler, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<Add>b__0(IElementHandler h, IElement v)
   at Microsoft.Maui.PropertyMapper.UpdatePropertyCore(String key, IElementHandler viewHandler, IElement virtualView)
   at Microsoft.Maui.PropertyMapper.UpdateProperties(IElementHandler viewHandler, IElement virtualView)
   at Microsoft.Maui.Handlers.ElementHandler.SetVirtualView(IElement view)
   at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.IScrollView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[UIKit.UIScrollView, Microsoft.iOS, Version=17.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065]].SetVirtualView(IView view)
   at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.IScrollView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[UIKit.UIScrollView, Microsoft.iOS, Version=17.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065]].SetVirtualView(IElement view)
   at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler)
   at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value)
   at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value)
   at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context)
   at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context)
   at Microsoft.Maui.Handlers.ContentViewHandler.UpdateContent(IContentViewHandler handler)
   at Microsoft.Maui.Handlers.ContentViewHandler.MapContent(IContentViewHandler handler, IContentView page)
   at Microsoft.Maui.PropertyMapper`2.<>c__DisplayClass5_0[[Microsoft.Maui.IContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Handlers.IContentViewHandler, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<Add>b__0(IElementHandler h, IElement v)
   at Microsoft.Maui.PropertyMapper.UpdatePropertyCore(String key, IElementHandler viewHandler, IElement virtualView)
   at Microsoft.Maui.PropertyMapper.UpdateProperties(IElementHandler viewHandler, IElement virtualView)
   at Microsoft.Maui.Handlers.ElementHandler.SetVirtualView(IElement view)
   at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.IContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.ContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IView view)
   at Microsoft.Maui.Handlers.ContentViewHandler.SetVirtualView(IView view)
   at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.IContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.ContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view)
   at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler)
   at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value)
   at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value)
   at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context)
   at Microsoft.Maui.Platform.ViewExtensions.ToHandler(IView view, IMauiContext context)
   at Microsoft.Maui.Controls.Platform.Compatibility.ShellSectionRenderer.PushPage(Page page, Boolean animated, TaskCompletionSource`1 completionSource)
   at Microsoft.Maui.Controls.Platform.Compatibility.ShellSectionRenderer.OnPushRequested(NavigationRequestedEventArgs e)
   at Microsoft.Maui.Controls.Platform.Compatibility.ShellSectionRenderer.OnNavigationRequested(Object sender, NavigationRequestedEventArgs e)
   at Microsoft.Maui.Controls.ShellSection.InvokeNavigationRequest(NavigationRequestedEventArgs args)
   at Microsoft.Maui.Controls.ShellSection.OnPushAsync(Page page, Boolean animated)
   at Microsoft.Maui.Controls.ShellSection.PushStackOfPages(List`1 pages, Nullable`1 animate)
   at Microsoft.Maui.Controls.ShellSection.GoToAsync(ShellNavigationRequest request, ShellRouteParameters queryData, IServiceProvider services, Nullable`1 animate, Boolean isRelativePopping)
   at Microsoft.Maui.Controls.ShellNavigationManager.GoToAsync(ShellNavigationParameters shellNavigationParameters, ShellNavigationRequest navigationRequest)
   at Logbook.Maui.ViewModels.FlightsPageViewModel.AddNewFlight() in /Users/wbeal/Code/Logbook/Logbook.Maui/ViewModels/FlightsPageViewModel.cs:line 85

I need to do some more investigating but for now I am stumped.

jfversluis commented 12 months ago

@varyamereon if that's the case please try and reproduce in a new .NET MAUI project built against .NET 8, add that project to a new issue and link to this one so we can track it properly. Please tag me and I will have a look, thanks!

varyamereon commented 12 months ago

Absolutely will do when I get a chance, still trying to find out the root cause.

ppereira-serviceonsites commented 11 months ago

@jfversluis ... I am also running into this issue.
Using net8.0-ios... This is currently halting my port to MAUI from going to production. It is very weird as the only way I can reliably reproduce it is this: high level app UI>>>: List page with drill down to detail page.

---updated this to simplify after what I found: To replicate follow this: 1) start at list and drill down to a detail page 2) click on a field to bring up the Keyboard/Picker/any iOS native UI 3) navigate back to list page... and then go into detail page again.

Looking at the call stack below... it seems to occur on a UITextView... drilling in... YOU ARE NOT GOING TO BELIEVE THIS... my field is populated from a DB and it has a double dash -- in it...

SOO... after all this... it seems it is definitely a result of having some special characters in a field... in combination with having previously brought up a keyboard/Picker/ any type of iOS native dialog P.S.> I tested Char(10) and Char(13) and no issues with them... I don't know how many other types of special character combinations exist... regardless... this needs to be fixed.

Value cannot be null. (Parameter 'fromPosition') 
----------    
at ObjCRuntime.ThrowHelper.ThrowArgumentNullException(String argumentName) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/ThrowHelper.cs:line 28    
at ObjCRuntime.NativeObjectExtensions.GetNonNullHandle(INativeObject self, String argumentName) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/INativeObject.cs:line 42    
at UIKit.UITextView.GetTextRange(UITextPosition fromPosition, UITextPosition toPosition) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/build/dotnet/ios/generated-sources/UIKit/UITextView.g.cs:line 565    
at Microsoft.Maui.Platform.TextInputExtensions.SetTextRange(IUITextInput platformView, Int32 start, Int32 selectedTextLength)    
at Microsoft.Maui.Controls.Platform.TextExtensions.UpdateText(IUITextInput textInput, InputView inputView, Boolean isEditing)    
at Microsoft.Maui.Controls.Platform.TextExtensions.UpdateText(UITextView textView, InputView inputView)    
at Microsoft.Maui.Controls.Editor.MapText(IEditorHandler handler, Editor editor)    
at Microsoft.Maui.PropertyMapperExtensions.<>c__DisplayClass2_0`2[[Microsoft.Maui.Controls.Editor, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Handlers.IEditorHandler, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<ReplaceMapping>b__0(IEditorHandler h, Editor v, Action`2 p)    
at Microsoft.Maui.PropertyMapperExtensions.<>c__DisplayClass1_0`2[[Microsoft.Maui.Controls.Editor, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Handlers.IEditorHandler, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<ModifyMapping>g__newMethod|0(IElementHandler handler, IElement view)    
at Microsoft.Maui.PropertyMapper`2.<>c__DisplayClass5_0[[Microsoft.Maui.IEditor, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Handlers.IEditorHandler, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<Add>b__0(IElementHandler h, IElement v)    
at Microsoft.Maui.PropertyMapper.UpdatePropertyCore(String key, IElementHandler viewHandler, IElement virtualView)    
at Microsoft.Maui.PropertyMapper.UpdateProperty(IElementHandler viewHandler, IElement virtualView, String property)    
at Microsoft.Maui.Handlers.ElementHandler.UpdateValue(String property)    
at Microsoft.Maui.Controls.Element.OnPropertyChanged(String propertyName)    
at Microsoft.Maui.Controls.BindableObject.SetValueActual(BindableProperty property, BindablePropertyContext context, Object value, Boolean currentlyApplying, SetValueFlags attributes, SetterSpecificity specificity, Boolean silent)    
at Microsoft.Maui.Controls.BindableObject.SetValueCore(BindableProperty property, Object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes, SetterSpecificity specificity)    
at Microsoft.Maui.Controls.BindingExpression.ApplyCore(Object sourceObject, BindableObject target, BindableProperty property, Boolean fromTarget, SetterSpecificity specificity)    
at Microsoft.Maui.Controls.BindingExpression.Apply(Boolean fromTarget)    
at Microsoft.Maui.Controls.BindingExpression.BindingExpressionPart.<PropertyChanged>b__50_0()    
at Microsoft.Maui.Controls.DispatcherExtensions.DispatchIfRequired(IDispatcher dispatcher, Action action)    
at Microsoft.Maui.Controls.BindingExpression.BindingExpressionPart.PropertyChanged(Object sender, PropertyChangedEventArgs args)    
at Microsoft.Maui.Controls.BindingExpression.WeakPropertyChangedProxy.OnPropertyChanged(Object sender, PropertyChangedEventArgs e)    
at CommunityToolkit.Mvvm.ComponentModel.ObservableObject.OnPropertyChanged(PropertyChangedEventArgs e)    
at CommunityToolkit.Mvvm.ComponentModel.ObservableObject.OnPropertyChanged(String propertyName)    
at CommunityToolkit.Mvvm.ComponentModel.ObservableObject.SetProperty[WODetails](WODetails& field, WODetails newValue, String propertyName)    
at SOSMobile.WorkOrders.WorkOrderDetailViewModel.set_WOInfo(WODetails value) in C:\Source\net8\SOSMobile\Features\WorkOrders\WorkOrderDetailViewModel.cs:line 40    
at SOSMobile.WorkOrders.WorkOrderDetailViewModel.RefreshData() in C:\Source\net8\SOSMobile\Features\WorkOrders\WorkOrderDetailViewModel.cs:line 138 
jyotsnar commented 10 months ago

I have the same issue in .NET 8 only in iOS, when setting the text on an 'Editor' via a view model binding property. I do have some '\n' and '\r' values in the text for formatting. This is a showstopper for moving to Maui.

Value cannot be null. (Parameter 'fromPosition')
"   at ObjCRuntime.ThrowHelper.ThrowArgumentNullException(String argumentName) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/ThrowHelper.cs:line 28
at ObjCRuntime.NativeObjectExtensions.GetNonNullHandle(INativeObject self, String argumentName) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/INativeObject.cs:line 42
at UIKit.UITextView.GetTextRange(UITextPosition fromPosition, UITextPosition toPosition) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/build/dotnet/ios/generated-sources/UIKit/UITextView.g.cs:line 565
at Microsoft.Maui.Platform.TextInputExtensions.SetTextRange(IUITextInput platformView, Int32 start, Int32 selectedTextLength)
at Microsoft.Maui.Controls.Platform.TextExtensions.UpdateText(IUITextInput textInput, InputView inputView, Boolean isEditing)
at Microsoft.Maui.Controls.Platform.TextExtensions.UpdateText(UITextView textView, InputView inputView)
at Microsoft.Maui.Controls.Editor.MapText(IEditorHandler handler, Editor editor)
at Microsoft.Maui.PropertyMapperExtensions.<>c__DisplayClass2_0`2[[Microsoft.Maui.Controls.Editor, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Handlers.IEditorHandler, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<ReplaceMapping>b__0(IEditorHandler h, Editor v, Action`2 p)
at Microsoft.Maui.PropertyMapperExtensions.<>c__DisplayClass1_0`2[[Microsoft.Maui.Controls.Editor, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Handlers.IEditorHandler, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<ModifyMapping>g__newMethod|0(IElementHandler handler, IElement view)
at Microsoft.Maui.PropertyMapper`2.<>c__DisplayClass5_0[[Microsoft.Maui.IEditor, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Handlers.IEditorHandler, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<Add>b__0(IElementHandler h, IElement v)
at Microsoft.Maui.PropertyMapper.UpdatePropertyCore(String key, IElementHandler viewHandler, IElement virtualView)
at Microsoft.Maui.PropertyMapper.UpdateProperty(IElementHandler viewHandler, IElement virtualView, String property)
at Microsoft.Maui.Handlers.ElementHandler.UpdateValue(String property)
at Microsoft.Maui.Controls.Element.OnPropertyChanged(String propertyName)
at Microsoft.Maui.Controls.BindableObject.SetValueActual(BindableProperty property, BindablePropertyContext context, Object value, Boolean currentlyApplying, SetValueFlags attributes, SetterSpecificity specificity, Boolean silent)
at Microsoft.Maui.Controls.BindableObject.SetValueCore(BindableProperty property, Object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes, SetterSpecificity specificity)
at Microsoft.Maui.Controls.BindingExpression.ApplyCore(Object sourceObject, BindableObject target, BindableProperty property, Boolean fromTarget, SetterSpecificity specificity)
at Microsoft.Maui.Controls.BindingExpression.Apply(Boolean fromTarget)
at Microsoft.Maui.Controls.BindingExpression.BindingExpressionPart.<PropertyChanged>b__50_0()
at Microsoft.Maui.Controls.DispatcherExtensions.DispatchIfRequired(IDispatcher dispatcher, Action action)
at Microsoft.Maui.Controls.BindingExpression.BindingExpressionPart.PropertyChanged(Object sender, PropertyChangedEventArgs args)
at Microsoft.Maui.Controls.BindingExpression.WeakPropertyChangedProxy.OnPropertyChanged(Object sender, PropertyChangedEventArgs e)"
ppereira-serviceonsites commented 10 months ago

@jyotsnar as this issue is actually closed, please see new issue I created and linked

jyotsnar commented 10 months ago

@jyotsnar as this issue is actually closed, please see new issue I created and linked

Oh okay, thank you very much

kubaflo commented 9 months ago

@jfversluis I could still replicate this issue, but I think the fix is here :) https://github.com/dotnet/maui/pull/20584