TextMemorySkill's Recall function blocks threads and causes WPF app to freeze
See original GitHub issueDescribe 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:
- Create a WPF app and add a button to the view, and create a new ISKFunction by calling
IKernel.CreateSemanticFunction
. - Configure the button with a RelayCommand.
- Let the RelayCommand to invoke
ISKFunction.InvokeAsync
- 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:
- Created 4 months ago
- Comments:7 (1 by maintainers)
Top GitHub Comments
the issue should be solved https://github.com/microsoft/semantic-kernel/pull/987
The recall skill looks blocking a thread. The following code is
recall
function. It callsToEnumerable
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.