Closed oscarsommerer closed 7 months ago
Have you tried setting the timeout on Plotly.NET.ImageExport.PuppeteerSharpRendererOptions.launchOptions
? Its weird though that your timeout occurs after 30 seconds, as the default is set to 60 seconds: https://github.com/plotly/Plotly.NET/blob/b9fc7cdc3fe27ed4a819fde6e73cebe711d2b8f4/src/Plotly.NET.ImageExport/PuppeteerSharpRenderer.fs#L14-L22
@kMutagene yep already tried that. Sadly this didn't change anything. I'm guessing that there is another timeout when doing puppeteer tasks somewhere? Inspecting my running processes clearly shows chrome running and taking a lot of CPU time
Having a look through the code it seems as this line in PuppeteerSharpRenderer.fs could be the offender? According to the Puppeteer docs it takes a NavigationOptions
object which contains a timeout whose default value seems to be 30 seconds?
Thanks for the pointer, that looks promising. If you want to have a go at it, feel free to open a PR. Otherwise I opened #394 to track this.
You can access navigationOptions
on PuppeteerSharpRendererOptions
with the next release.
Your snippet took longer than 10 minutes, so i reduced the amount of points a bit for testing. This took around 1 min for me :
let x = [ for i in 0 .. 500000 -> System.Random.Shared.Next() ]
let y = [ for i in 0 .. 500000 -> System.Random.Shared.Next() ]
PuppeteerSharpRendererOptions.navigationOptions.Timeout <- 0 // setting to 0 means no timeout
Chart.PointDensity(x = x, y = y)
|> Chart.toBase64PNGString (Width = 300, Height = 300)
Description
Calling
Chart.toBase64PNGString
(or any other export function) on a chart backed by a large enough dataset leads to a PuppeteerSharp timeout.I'm trying to render a PointDensity chart with about one million items for the x/y values in a .NET interactive session (vscode polyglot notebook). Without exporting, this is done in a few seconds, but when trying to export the chart I get a timeout exception from PuppeteerSharp.
Repro steps
Run the F# following snippet
Expected behavior
The export should return a base64 PNG string, even if generating the image takes longer than 30 seconds.
I'm wondering if it would be feasible to supply a custom timeout?
Actual behavior
The function throws a TimeoutException after about 30 seconds.
Known workarounds
Rendering the chart without the static export function and using the export button works as expected.
Reducing the number of items to about one hundred thousand also seems to let PuppeteerSharp render the image fast enough, so as to not run into the timeout
Related information