-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
App crashes when entry bound to float value with fractional format #25728
Comments
This issue doesn't occur on 8.0.92, 8.0.93 and 9.0.0-rc.1.24453.9. |
Have done more tests, and also happens with the Editor. |
After doing some quick review the origin of the crash happens here
Because the values for the oldText and newText are incorrect.
|
Version with bug: The problem is only on Android, everything works on iOS. When changing the cursor position in Entry, the following error occurs: [InputEventSender] Exception dispatching finished signal for seq=12 |
Just encountered this as well. |
I have same problem on android. I using NET 9 NET MAUI - dotnet version 9.0.100. When clear all characters and after call entry.Text = "0"; application crash on android. On windows or iOS all OK. public partial class EntryBehaviorPort : Behavior ERROR OUTPUT: ERROR LOG: [AndroidRuntime] Shutting down VM |
For some extra context, in my case, the issue is occurring when attached to a ValueConverter that clears the Entry when it is anything other than a parsable integer:
|
This has to do with this bug over at Google. From what I understand the cause is that the text length is different between different events in the EditText. Probably because the field in the binding will return a formatted value like 1.00 when you actually input a 1. If I set the
|
Reverting this commit makes the crash go away, so definitely introduced somewhere there. |
There is no great solution for this right now unfortunately. A workaround is this, if you need it for #if ANDROID
Microsoft.Maui.Handlers.EntryHandler.PlatformViewFactory =
(handler) =>
{
var editText = new AndroidX.AppCompat.Widget.AppCompatEditText(handler.Context);
editText.EmojiCompatEnabled = false;
return editText;
};
#endif However, we're using a So potentially with this workaround you might hit something else, but I think it should be mostly OK. Bumping down the priority a bit because we have some options to work with and I don't think a whole lot of people will be impacted by this. Hopefully it will be fixed on Google's side soon 🤞 |
Upon retrying it seems that a custom handler does work, not sure why I thought it didn't work earlier. If you place this in your // Entry
Microsoft.Maui.Handlers.EntryHandler.Mapper.AppendToMapping("DisableEmojiCompat", (handler, view) =>
{
handler.PlatformView.EmojiCompatEnabled = false;
});
// Editor
Microsoft.Maui.Handlers.EditorHandler.Mapper.AppendToMapping("DisableEmojiCompat", (handler, view) =>
{
handler.PlatformView.EmojiCompatEnabled = false;
}); If you want to make it specific to a certain // Entry
Microsoft.Maui.Handlers.EntryHandler.Mapper.AppendToMapping("DisableEmojiCompat", (handler, view) =>
{
if (view is NoEmojiEntry)
{
handler.PlatformView.EmojiCompatEnabled = false;
}
}); More in detail is explained: https://learn.microsoft.com/dotnet/maui/user-interface/handlers/customize Please let me know if that works for people! |
@jfversluis, I tried your workaround and it works! I put your code in |
A temporary solution:
The cursor position is now correct and there are no errors. |
Description
When I bound Text property of Entry to float value with StringFormat='{0:F2}', app crashes when I change value with the following exception:
Java.Lang.IllegalArgumentException: 'end should be < than charSequence length'
.I run my app on android 14 on Xiaomi 13.
Steps to Reproduce
or
Java.Lang.IllegalArgumentException: 'end should be < than charSequence length'
.Link to public reproduction project repository
MauiStringFormatIssue.zip
Version with bug
9.0.0-rc.2.24503.2
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
No response
Affected platforms
Android
Affected platform versions
Android 14 UKQ1.230804.001
Did you find any workaround?
Do not use string format with float value
Relevant log output
13:21:35:821 [AndroidRuntime] FATAL EXCEPTION: main
13:21:35:821 [AndroidRuntime] Process: com.companyname.mauistringformatissue, PID: 5792
13:21:35:821 [AndroidRuntime] java.lang.IllegalArgumentException: end should be < than charSequence length
13:21:35:821 [AndroidRuntime] at androidx.core.util.Preconditions.checkArgument(Preconditions.java:51)
13:21:35:821 [AndroidRuntime] at androidx.emoji2.text.EmojiCompat.process(EmojiCompat.java:1127)
13:21:35:821 [AndroidRuntime] at androidx.emoji2.viewsintegration.EmojiTextWatcher.afterTextChanged(EmojiTextWatcher.java:99)
13:21:35:821 [AndroidRuntime] at android.widget.TextView.sendAfterTextChanged(TextView.java:12420)
13:21:35:821 [AndroidRuntime] at android.widget.TextView$ChangeWatcher.afterTextChanged(TextView.java:15930)
13:21:35:821 [AndroidRuntime] at android.text.SpannableStringBuilder.sendAfterTextChanged(SpannableStringBuilder.java:1278)
13:21:35:821 [AndroidRuntime] at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:578)
13:21:35:821 [AndroidRuntime] at androidx.emoji2.text.SpannableBuilder.replace(SpannableBuilder.java:308)
13:21:35:821 [AndroidRuntime] at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:508)
13:21:35:821 [AndroidRuntime] at androidx.emoji2.text.SpannableBuilder.replace(SpannableBuilder.java:298)
13:21:35:821 [AndroidRuntime] at androidx.emoji2.text.SpannableBuilder.replace(SpannableBuilder.java:48)
13:21:35:821 [AndroidRuntime] at android.text.method.NumberKeyListener.onKeyDown(NumberKeyListener.java:129)
13:21:35:821 [AndroidRuntime] at android.widget.TextView.doKeyDown(TextView.java:9566)
13:21:35:821 [AndroidRuntime] at android.widget.TextView.onKeyDown(TextView.java:9334)
13:21:35:821 [AndroidRuntime] at android.view.KeyEvent.dispatch(KeyEvent.java:2934)
13:21:35:821 [AndroidRuntime] at android.view.View.dispatchKeyEvent(View.java:15772)
13:21:35:821 [AndroidRuntime] at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1981)
13:21:35:821 [AndroidRuntime] at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1981)
13:21:35:821 [AndroidRuntime] at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1981)
13:21:35:821 [AndroidRuntime] at androidx.core.widget.NestedScrollView.dispatchKeyEvent(NestedScrollView.java:686)
13:21:35:821 [AndroidRuntime] at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1981)
13:21:35:821 [AndroidRuntime] at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1981)
13:21:35:821 [AndroidRuntime] at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1981)
13:21:35:821 [AndroidRuntime] at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1981)
13:21:35:821 [AndroidRuntime] at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1981)
13:21:35:821 [AndroidRuntime] at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1981)
13:21:35:821 [AndroidRuntime] at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1981)
13:21:35:821 [AndroidRuntime] at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1981)
13:21:35:821 [AndroidRuntime] at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1981)
13:21:35:821 [AndroidRuntime] at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1981)
13:21:35:821 [AndroidRuntime] at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1981)
13:21:35:821 [AndroidRuntime] at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1981)
13:21:35:821 [AndroidRuntime] at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1981)
13:21:35:821 [AndroidRuntime] at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1981)
13:21:35:821 [AndroidRuntime] at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1981)
13:21:35:821 [AndroidRuntime] at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1981)
13:21:35:821 [AndroidRuntime] at com.android.internal.policy.DecorView.superDispatchKeyEvent(DecorView.java:554)
13:21:35:821 [AndroidRuntime] at com.android.internal.policy.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1898)
13:21:35:821 [AndroidRuntime] at android.app.Activity.dispatchKeyEvent(Activity.java:4542)
13:21:35:821 [AndroidRuntime] at androidx.core.app.ComponentActivity.superDispatchKeyEvent(ComponentActivity.kt:103)
13:21:35:821 [AndroidRuntime] at androidx.core.view.KeyEventDispatcher.dispatchKeyEvent(KeyEventDispatcher.java:85)
13:21:35:821 [AndroidRuntime] at androidx.core.app.ComponentActivity.dispatchKeyEvent(ComponentActivity.kt:117)
13:21:35:821 [AndroidRuntime] at androidx.appcompat.app.AppCompatActivity.dispatchKeyEvent(AppCompatActivity.java:604)
13:21:35:821 [AndroidRuntime] at androidx.appcompat.view.WindowCallbackWrapper.dispatchKeyEvent(WindowCallbackWrapper.java:59)
13:21:35:821 [AndroidRuntime] at androidx.appcompat.app.AppCompatDelegateImpl$AppCompatWindowCallback.dispatchKeyEvent(AppCompatDelegateImpl.java:3397)
13:21:35:821 [AndroidRuntime] at com.android.internal.policy.DecorView.dispatchKeyEvent(DecorView.java:437)
13:21:35:822 [AndroidRuntime] at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:7717)
13:21:35:822 [AndroidRuntime] at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:7565)
13:21:35:822 [AndroidRuntime] at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:6953)
13:21:35:822 [AndroidRuntime] at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:7010)
13:21:35:822 [AndroidRuntime] at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:6976)
13:21:35:822 [AndroidRuntime] at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:7141)
13:21:35:822 [AndroidRuntime] at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:6984)
13:21:35:822 [AndroidRuntime] at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:7198)
13:21:35:822 [AndroidRuntime] at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:6957)
13:21:35:822 [AndroidRuntime] at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:7010)
13:21:35:822 [AndroidRuntime] at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:6976)
13:21:35:822 [AndroidRuntime] at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:6984)
13:21:35:822 [AndroidRuntime] at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:6957)
13:21:35:822 [AndroidRuntime] at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:10124)
13:21:35:822 [AndroidRuntime] at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:10075)
13:21:35:822 [AndroidRuntime] at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:10039)
13:21:35:822 [AndroidRuntime] at android.view.ViewRootImpl$ViewRootHandler.handleMessageImpl(ViewRootImpl.java:6709)
13:21:35:822 [AndroidRuntime] at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:6566)
13:21:35:822 [AndroidRuntime] at android.os.Handler.dispatchMessage(Handler.java:106)
13:21:35:822 [AndroidRuntime] at android.os.Looper.loopOnce(Looper.java:224)
13:21:35:822 [AndroidRuntime] at android.os.Looper.loop(Looper.java:318)
13:21:35:822 [AndroidRuntime] at android.app.ActivityThread.main(ActivityThread.java:8777)
13:21:35:822 [AndroidRuntime] at java.lang.reflect.Method.invoke(Native Method)
13:21:35:822 [AndroidRuntime] at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:561)
13:21:35:822 [AndroidRuntime] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1013)
13:21:36:154 Java.Lang.IllegalArgumentException: 'end should be < than charSequence length'
The text was updated successfully, but these errors were encountered: