plotly / plotly/Plotly.NET

[ImageExport] Synchronous invokation deadlock still occures

Open
#323 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area: ImageExport Type: Bug
Dominant language
F#
Stars
860
Forks
99
Avg merge
22m
Merged PRs (30d)
1

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the ImageExport synchronous path, especially page.CloseAsync() and AsyncHelper.taskSyncUnit, and compare it with the working ToBase64PNGStringAsync() path. Reproduce the issue using the Avalonia button handler shown in the report; it is done when chart.ToBase64PNGString() terminates and the following exception is reached.

Written by the indexing model from the issue text.

Assessment

Tech stack
fsharp
Domain
data-visualization, desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.