Skip to content

[BUG] Cancel being called on a disposed CancellationTokenSource #2310

@matt-bartholomew

Description

@matt-bartholomew

Is there an existing issue for this?

  • I have searched the existing issues

Did you read the "Reporting a bug" section on Contributing file?

Current Behavior

The app is a fairly basic app that renders questionnaires (from JSON) into popups, or pages, that can be filled out. This is used as a package in other apps we have. Inside of the code is a sample app. When you load up a form and click into a textbox, the app crashes, with the following being printed to the console. From the best I can tell, it looks like Cancel() is called on a disposed cancellationtokensource. The app uses validation behaviors based on the question type.

System.ObjectDisposedException: 'Loading...'

System.ObjectDisposedException: 'The CancellationTokenSource has been disposed.'

[mono-rt] [ERROR] FATAL UNHANDLED EXCEPTION: System.ObjectDisposedException: The CancellationTokenSource has been disposed.
[mono-rt] at System.Threading.CancellationTokenSource.ThrowIfDisposed()
[mono-rt] at System.Threading.CancellationTokenSource.Cancel(Boolean throwOnFirstException)
[mono-rt] at System.Threading.CancellationTokenSource.Cancel()
[mono-rt] at CommunityToolkit.Maui.Behaviors.ValidationBehavior.ResetValidationTokenSource(CancellationTokenSource newTokenSource)
[mono-rt] at CommunityToolkit.Maui.Behaviors.ValidationBehavior.UpdateStateAsync(VisualElement view, ValidationFlags flags, Boolean isForced, Nullable`1 parentToken)
[mono-rt] at CommunityToolkit.Maui.Behaviors.ValidationBehavior.OnViewPropertyChanged(VisualElement sender, PropertyChangedEventArgs e)
[mono-rt] at System.Threading.Tasks.Task.<>c.b__128_0(Object state)
[mono-rt] at Android.App.SyncContext.<>c__DisplayClass2_0.b__0() in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.App/SyncContext.cs:line 36
[mono-rt] at Java.Lang.Thread.RunnableImplementor.Run() in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Java.Lang/Thread.cs:line 37
[mono-rt] at Java.Lang.IRunnableInvoker.n_Run(IntPtr jnienv, IntPtr native__this) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/net8.0/android-34/mcw/Java.Lang.IRunnable.cs:line 84
[mono-rt] at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V(_JniMarshal_PP_V callback, IntPtr jnienv, IntPtr klazz) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:line 22

Expected Behavior

You should be able to open the form, click into a textbox, and fill out the form w/o issue.

Steps To Reproduce

  1. Open solution, navigate to main branch, and build and run for Android.
  2. Once app loads, select button "Fill Out Form".
  3. Click into the "Number of Milk Crates Delivered" entry and app will crash.

Link to public reproduction project repository

https://github.com/matt-bartholomew/MobileForms

Environment

  • .NET MAUI CommunityToolkit: 9.0.3
  • OS: Android XT3 running Android 9
  • .NET MAUI: 9.0.0-rc.1.24453.9

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/viewsIssue/Discussion/PR that has to do with ViewsbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions