Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue when using BindableLayout and Entry/Editor with special characters #19954

Closed
ppereira-serviceonsites opened this issue Jan 17, 2024 · 6 comments · Fixed by #20584
Closed
Labels
area-controls-editor Editor area-controls-entry Entry area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter fixed-in-8.0.10 fixed-in-9.0.0-preview.3.10457 t/bug Something isn't working
Milestone

Comments

@ppereira-serviceonsites
          @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...

  • what the system does is the first time, there is no issues... is displays the double dash as 2 characters...
  • if you click on ANY field to bring up the keyboard... in my case, I consider it dirty and save as I navigate back.
  • it then converts that double dash to a special long dash
  • next time in, it barfs with the error below as it tries to show the special character.

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 

Originally posted by @ppereira-serviceonsites in #15937 (comment)

@ppereira-serviceonsites ppereira-serviceonsites changed the title @jfversluis ... I am also running into this issue. Issue when using BindableLayout and Entry/Editor with special characters Jan 17, 2024
@jyotsnar
Copy link

jyotsnar commented Jan 17, 2024

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)"

@jsuarezruiz jsuarezruiz added t/bug Something isn't working area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter labels Jan 18, 2024
@MichaelShapiro
Copy link

I can consistently reproduce this issue when I enter double dash "--" into the Editor on iOS, save it to the db, and then return back to the page with an Editor... and boom, crash. Looks to me as double dash is the problem for the iOS to read and interpret.

@jyotsnar
Copy link

I was able to fix the issue by replacing '\n' and '\r\n' values with '\r' before setting the text in the editor

@jyotsnar
Copy link

I was able to fix the issue by replacing '\n' and '\r\n' values with '\r' before setting the text in the editor

Actually this fixed the crash only on the simulator not the actual phone - not sure what the difference is

@jyotsnar
Copy link

Found that it was because of a "--" that did not work on some iOS devices as @MichaelShapiro mentioned

@kubaflo
Copy link
Contributor

kubaflo commented Feb 14, 2024

@jyotsnar @ppereira-serviceonsites a possible fix here :) #20584

@github-actions github-actions bot locked and limited conversation to collaborators May 4, 2024
@Eilon Eilon removed the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label May 10, 2024
@samhouts samhouts added this to the .NET 8 SR3 milestone May 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-editor Editor area-controls-entry Entry area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter fixed-in-8.0.10 fixed-in-9.0.0-preview.3.10457 t/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants