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.

TextMemorySkill's Recall function blocks threads and causes WPF app to freeze

See original GitHub issue

Describe the bug I crafted a WPF app and hooked a button with a RelayCommand that will eventually invoke ISKFunction.InvokeAsync method. Even without the await, it will still blocks the WPF app. And this exact same function, when running with a console app, produced results and finished within several seconds. I am using <PackageReference Include="Microsoft.SemanticKernel" Version="0.12.207.1-preview" /> To Reproduce Steps to reproduce the behavior:

  1. Create a WPF app and add a button to the view, and create a new ISKFunction by calling IKernel.CreateSemanticFunction.
  2. Configure the button with a RelayCommand.
  3. Let the RelayCommand to invoke ISKFunction.InvokeAsync
  4. Run debug in Visual Studio.

Expected behavior Clicking the button shouldn’t block the WPF app.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Windows 11
  • IDE: Visual Studio
  • NuGet Package Version: <PackageReference Include="Microsoft.SemanticKernel" Version="0.12.207.1-preview" />

Additional context The VS debug output also shows some interesting information:

The thread 0x5fb8 has exited with code 0 (0x0).
The thread 0x25f0 has exited with code 0 (0x0).
Exception thrown: 'System.IO.IOException' in System.Net.Sockets.dll
Exception thrown: 'System.IO.IOException' in System.Net.Security.dll
Exception thrown: 'System.IO.IOException' in System.Private.CoreLib.dll
The thread 0x622c has exited with code 0 (0x0).
The thread 0x7b14 has exited with code 0 (0x0).
The thread 0x3868 has exited with code 0 (0x0).
The thread 0x1788 has exited with code 0 (0x0).

But the WPF process is just blocked without seeing any exceptions at all.

Issue Analytics

  • State:closed
  • Created 4 months ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
dluccommented, May 15, 2023
1reaction
runceelcommented, May 13, 2023

The recall skill looks blocking a thread. The following code is recall function. It calls ToEnumerable method to get result.

https://github.com/microsoft/semantic-kernel/blob/main/dotnet/src/SemanticKernel/CoreSkills/TextMemorySkill.cs#L124

I thought it might be a good idea to change the title of the Issue to something like TextMemorySkill’s Recall function blocks threads to clarify this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

C# WPF application freezed over time
The easiest way to debug this is to attach a debugger (Visual Studio can do this). Then look at what the threads are...
Read more >
WPF render thread failures - .NET Framework
Common causes of the failures​​ The most common bucket of WPF render thread failures is associated with video hardware or driver problems.
Read more >
Threading Model - WPF .NET Framework
Typically, WPF applications start with two threads: one for handling rendering and another for managing the UI.
Read more >
Find the Cause of a UI Freeze | dotTrace Documentation
This indicates that the application waits for user input in a message loop. We can simply ignore these methods when analyzing the snapshot....
Read more >
C# Deadlocks in Depth – Part 2
The is a simple WPF application; OnButtonClick is an ... freeze it; When going back to the UI Thread, you can potentially cause...
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