microsoft / microsoft/onnxruntime-genai
OnnxRuntimeGenAIChatClient in WINUI3 S4 Hibernation Scenario: Model Residue When Not Disposed, Crash on Dispose() Call
- Dominant language
- C++
- Stars
- 1.1k
- Forks
- 354
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 85
Description
Untitled Document
Describe the bug
After initializing the model using OnnxRuntimeGenAIChatClient in WINUI3, when entering S4, we observed that the memory usage of the NPU has dropped to 0, but the OnnxRuntimeGenAIChatClient was not released. During inference, it remains in the inference state without any data returned. Therefore, we added Dispose() when entering S4. However, an uncatchable crash occurs when calling dispose() on OnnxRuntimeGenAIChatClient while entering S4.
```
PowerManager.SystemSuspendStatusChanged += PowerManager_SystemSuspendStatusChanged;
private void PowerManager_SystemSuspendStatusChanged(object sender, object e)
{
if (PowerManager.SystemSuspendStatus == SystemSuspendStatus.Entering)
{
try
{
model.Dispose();//model is OnnxRuntimeGenAIChatClient
}
catch
{
}
finally
{
}
}
Debug.WriteLine($"PowerManager_SystemSuspendStatusChanged:{Enum.GetName(PowerManager.SystemSuspendStatus)}");
}
```
To Reproduce
Steps to reproduce the behavior:
1. Initialize the model
2. Wait for the initialization to complete
3. Enter S4 (if there is no crash, try entering S4 multiple times)
Expected behavior
The model should be released normally.
Desktop (please complete the following information)
- OS: Windows 11 Home 25H2 26200.6588
- OnnxRuntimeGenAI.QNN: 0.10.0
- NPU driver: 30.0.140.1000/30.0.145.1000
Additional context
You can add any other relevant information about the problem here.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with PowerManager_SystemSuspendStatusChanged and the model.Dispose() call shown in the issue. Reproduce by initializing OnnxRuntimeGenAIChatClient, waiting for initialization, and entering S4 repeatedly. Done means the model is released normally during suspend without an uncatchable crash or inference remaining stuck.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- ai, desktop, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100