[ImageExport] Synchronous invokation deadlock still occures
還沒有人認領這個 Issue。
- 主要語言
- F#
- 星號
- 860
- 分支
- 99
- 平均合併
- 22 分鐘
- 30 天內合併 PR
- 1
描述
Problem
This is the problem that we intended to fix with PR #321. It is fixed partially.
After we migrated to tasks instead of F#'s async, plus we changed
- page.CloseAsync() |> Async.AwaitTask |> Async.RunSynchronously
+ page.CloseAsync() |> AsyncHelper.taskSyncUnit
The async version works, as in, completes. However, the synchronous version still does not terminate
Reproduction
I'm going to present the repro with AvaloniaUI, but it should be as well reproduced in WinForms or WPF if you're on Windows.
1. Install templates & create project:
dotnet new --install Avalonia.Templates
dotnet new avalonia.mvvm -o TestAsync -n TestAsync
cd TestAsync/
2. Install the package
Add source & install the latest
dotnet new nugetconfig
dotnet nuget add source https://www.myget.org/F/plotly-net-nightly/api/v3/index.json
dotnet add package Plotly.NET.ImageExport --prerelease
3. Adding a component
Go to MainWindow.axaml and replace some default thingy with a button
- <TextBlock Text="{Binding Greeting}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
+ <Button Click="Button_OnClick" />
4. Adding event
Go to MainWindow.axaml.cs and add this method:
private async void Button_OnClick(object? sender, RoutedEventArgs e)
{
var layout = new Layout();
var trace = new Trace("bar");
var fig = GenericChart.Figure.create(ListModule.OfSeq(new[] { trace }), layout);
var chart = GenericChart.fromFigure(fig);
// This works now
await chart.ToBase64PNGStringAsync();
// This never terminates
chart.ToBase64PNGString();
// If we get to this line, it terminated
throw new Exception();
}
5. Run
dotnet run
Now, once it started, click the button. Successful completion is when the exception occurs.
貢獻指南
這個儲存庫沒有索引到貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從 ImageExport 的同步路徑開始,尤其是 page.CloseAsync() 和 AsyncHelper.taskSyncUnit,並將其與正常運作的 ToBase64PNGStringAsync() 路徑進行比較。使用報告中所示的 Avalonia 按鈕處理常式重現此問題;當 chart.ToBase64PNGString() 終止並到達以下例外狀況時,即完成。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- fsharp
- 領域
- data-visualization, desktop
- Issue 類型
- 缺陷
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100