[ImageExport] Synchronous invokation deadlock still occures
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- F#
- Star
- 860
- Fork
- 99
- Merge trung bình
- 22 phút
- Pull request đã merge (30 ngày)
- 1
Mô tả
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.
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu với đường dẫn đồng bộ của ImageExport, đặc biệt là page.CloseAsync() và AsyncHelper.taskSyncUnit, rồi so sánh với đường dẫn ToBase64PNGStringAsync() đang hoạt động. Tái hiện sự cố bằng trình xử lý nút Avalonia được hiển thị trong báo cáo; hoàn tất khi chart.ToBase64PNGString() kết thúc và gặp ngoại lệ sau.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- fsharp
- Lĩnh vực
- data-visualization, desktop
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100