plotly / plotly/Plotly.NET

[ImageExport] Synchronous invokation deadlock still occures

Offen
#323 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Area: ImageExport Type: Bug
Vorherrschende Sprache
F#
Sterne
860
Forks
99
Ø Merge
22 Min.
Gemergte PRs (30 T.)
1

Beschreibung

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.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit dem synchronen ImageExport-Pfad, insbesondere page.CloseAsync() und AsyncHelper.taskSyncUnit, und vergleiche ihn mit dem funktionierenden ToBase64PNGStringAsync()-Pfad. Reproduziere das Problem mit dem im Bericht gezeigten Avalonia-Button-Handler; es ist erledigt, wenn chart.ToBase64PNGString() beendet wird und die folgende Ausnahme auftritt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
fsharp
Bereich
data-visualization, desktop
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.