Debugging async methods with Xamarin is very confusing

I've been tearing my hair with this problem for some time so I think it's time to report it. 

I'm writing a Xamarin Forms project and there, naturally, most of the data layer is heavily asynchronous. The problem is debugging async methods is extremely difficult with Rider. What happens is:

 

  • I put a breakpoint on an `async` method. Debugger breaks
  • I step over (F10) the async method

Very very often the debugger then breaks somewhere inside the async call tree, very often inside the `Task` class, here:

internal bool NotifyDebuggerOfWaitCompletionIfNecessary()
{
// Notify the debugger if of any of the tasks we've waited on requires notification
if (IsWaitNotificationEnabled && ShouldNotifyDebuggerOfWaitCompletion)
{
NotifyDebuggerOfWaitCompletion();
return true;
}
return false; // <-- DEBUGGER BREAKS HERE
}

I have turned off "Enable external source debug"

This makes async debugging extremely confusing with constant mental context switching and it's very easy to loose track. I often find myself writing most of the code in Rider and then resort to Visual Studio for a leaner debugging experience.

This problem have persisted, throigh all versions, since I started using Rider full time this summer.

Is there anything I can do or is it simply a bug?

Best regards,
Jonas

4 comments
Comment actions Permalink

Hi Jonas! 

Thank you for your report. First, could you please tell me, what OS do you use and what is your current Rider version? 

Also, I would appreciate if you could attach a sample solution where you were able to reproduce this case. You can attach it here or add privately to a new issue via Help | Contact support or Help | Report a bug.

Thank you! 

0
Comment actions Permalink

My Rider version is 2020.2.4, running on MacOS Catalina 10.15.7

I tossed together a small xplat app (iOS + Android) to repro the problem. In that mini app I can actually step over async methods but when stepping into the async method I end up in external code (in TaskAwaiter class) even though I have turned that option off in preferences.

I can't find a way to attach the solution to this post though. How do I do that? Dropping the zip into the post yielded an error message ("you can only upload images).

Wanted to mention also: I spoke to  colleague yesterday that is also using Rider for Xamarin development and he (and his teammates) are seeing the exact same thing. Like me, they have started to adopt a workaround to keep setting breakpoints on the statement following every async call and step over by selecting "Resume program F5".

Maybe it's something that happens as the solution grows in complexity?

0
Comment actions Permalink

Any JetBrains update on this?

0
Comment actions Permalink

Hi Jonas Rembratt

Sorry for the delay. 

Please, try to update to the latest version as this looks like a known issue that is already resolved in 2020.3.

Also, you can upload a solution via our upload service and share ID with us if this will be still necessary. 

0

Please sign in to leave a comment.