question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

System.Threading.Tasks.TaskCanceledException will crash the application

See original GitHub issue

Hey, I am facing a problem in my Xamarin.Forms Android Application. I am using the current Nuget Package. In my application I have the imagecontrol used in a TelerikListview. Sometimes when I scroll through the Listview I get the following Exception and the Application crashs:

03-15 11:10:38.518 I/MonoDroid( 3392): UNHANDLED EXCEPTION: 03-15 11:10:38.519 I/MonoDroid( 3392): System.Threading.Tasks.TaskCanceledException: A task was canceled. 03-15 11:10:38.519 I/MonoDroid( 3392): at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0002d] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:179 03-15 11:10:38.519 I/MonoDroid( 3392): at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156 03-15 11:10:38.519 I/MonoDroid( 3392): at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128 03-15 11:10:38.519 I/MonoDroid( 3392): at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:535 03-15 11:10:38.519 I/MonoDroid( 3392): at FFImageLoading.Work.ImageLoaderTask2+<<Init>b__3_0>d[TImageContainer,TImageView].MoveNext () [0x00057] in C:\projects\ffimageloading\source\FFImageLoading.Common\Work\ImageLoaderTask.cs:40 03-15 11:10:38.519 I/MonoDroid( 3392): --- End of stack trace from previous location where exception was thrown --- 03-15 11:10:38.519 I/MonoDroid( 3392): at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 03-15 11:10:38.519 I/MonoDroid( 3392): at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00027] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:176 03-15 11:10:38.519 I/MonoDroid( 3392): at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156 03-15 11:10:38.519 I/MonoDroid( 3392): at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128 03-15 11:10:38.519 I/MonoDroid( 3392): at System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwaiter.GetResult () [0x00000] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:447 03-15 11:10:38.519 I/MonoDroid( 3392): at FFImageLoading.Work.ImageLoaderTask2+<Init>d__3[TImageContainer,TImageView].MoveNext () [0x00075] in C:\projects\ffimageloading\source\FFImageLoading.Common\Work\ImageLoaderTask.cs:38 03-15 11:10:38.519 I/MonoDroid( 3392): — End of stack trace from previous location where exception was thrown — 03-15 11:10:38.519 I/MonoDroid( 3392): at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 03-15 11:10:38.519 I/MonoDroid( 3392): at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00027] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:176 03-15 11:10:38.519 I/MonoDroid( 3392): at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156 03-15 11:10:38.519 I/MonoDroid( 3392): at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128 03-15 11:10:38.519 I/MonoDroid( 3392): at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:113 03-15 11:10:38.519 I/MonoDroid( 3392): at FFImageLoading.Work.WorkScheduler+<LoadImage>d__44.MoveNext () [0x0022e] in C:\projects\ffimageloading\source\FFImageLoading.Common\Work\WorkScheduler.cs:163 03-15 11:10:38.519 I/MonoDroid( 3392): — End of stack trace from previous location where exception was thrown — 03-15 11:10:38.519 I/MonoDroid( 3392): at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 03-15 11:10:38.519 I/MonoDroid( 3392): at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<ThrowAsync>m__0 (System.Object state) [0x00000] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1018 03-15 11:10:38.519 I/MonoDroid( 3392): at Android.App.SyncContext+<Post>c__AnonStorey0.<>m__0 () [0x00000] in /Users/builder/data/lanes/4009/9578cdcd/source/xamarin-android/src/Mono.Android/Android.App/SyncContext.cs:35 03-15 11:10:38.519 I/MonoDroid( 3392): at Java.Lang.Thread+RunnableImplementor.Run () [0x0000b] in /Users/builder/data/lanes/4009/9578cdcd/source/xamarin-android/src/Mono.Android/Java.Lang/Thread.cs:36 03-15 11:10:38.519 I/MonoDroid( 3392): at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] in /Users/builder/data/lanes/4009/9578cdcd/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Java.Lang.IRunnable.cs:81 03-15 11:10:38.519 I/MonoDroid( 3392): at (wrapper dynamic-method) System.Object:eac2b394-0725-46b6-998d-94d98e08006b (intptr,intptr) 03-15 11:10:38.521 W/art ( 3392): JNI RegisterNativeMethods: attempt to register 0 native methods for android.runtime.JavaProxyThrowable 03-15 11:10:38.522 D/Mono ( 3392): DllImport searching in: ‘__Internal’ (‘(null)’). 03-15 11:10:38.522 D/Mono ( 3392): Searching for ‘java_interop_jnienv_throw’. 03-15 11:10:38.522 D/Mono ( 3392): Probing ‘java_interop_jnienv_throw’. 03-15 11:10:38.522 D/Mono ( 3392): Found as ‘java_interop_jnienv_throw’. An unhandled exception occured.

03-15 11:10:39.195 E/mono ( 3392): 03-15 11:10:39.195 E/mono ( 3392): Unhandled Exception: 03-15 11:10:39.195 E/mono ( 3392): System.Threading.Tasks.TaskCanceledException: A task was canceled. 03-15 11:10:39.195 E/mono-rt ( 3392): [ERROR] FATAL UNHANDLED EXCEPTION: System.Threading.Tasks.TaskCanceledException: A task was canceled. 03-15 11:10:39.195 W/art ( 3392): Native thread exiting without having called DetachCurrentThread (maybe it’s going to use a pthread_key_create destructor?): Thread[21,tid=3419,Native,Thread*=0x94df3300,peer=0x12e950a0,“Thread-218”] `

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
molinchcommented, Mar 15, 2017

This is fixed by @AndreiMisiukevich PR. However as described in my comment, here: https://github.com/luberda-molinet/FFImageLoading/pull/529#issuecomment-286757230 It would be better to have a global look on the async void usage.

1reaction
AndreiMisiukevichcommented, Mar 15, 2017

I tried to fix this issue in my PR https://github.com/luberda-molinet/FFImageLoading/pull/529 It include fix for this crash

Read more comments on GitHub >

github_iconTop Results From Across the Web

Exception in a task not causing the application to crash
If I am not wrong, a Task uses a background thread so the exception should be propagate to the Main thread and crash...
Read more >
System.Threading.Tasks.TaskCanceledException thrown ...
I am using Visual Studio (Version 16.8.1) to debug a wpf application targeting net480. When closing the application a System.Threading.Tasks.
Read more >
Understanding and resolving app crashes and failures in ...
Threading.Tasks.TaskCanceledException exception. The outer exception fails in mscorlib_ni!System.Runtime.CompilerServices.TaskAwaiter.
Read more >
Solved: TaskCanceledException when debugging
Message: An unhandled exception of type 'System.Threading.Tasks.TaskCanceledException' occurred in WindowsBase.dll
Read more >
TaskCanceledException Class (System.Threading.Tasks)
Initializes a new instance of the TaskCanceledException class with a reference to the Task that has been canceled. Properties. CancellationToken. Gets a token ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found