Bonito.jl icon indicating copy to clipboard operation
Bonito.jl copied to clipboard

In html export of Pluto notebook, only one WGLMakie plot is shown

Open greimel opened this issue 3 years ago • 7 comments
trafficstars

cross-post from https://github.com/fonsp/Pluto.jl/issues/1822 and https://github.com/JuliaPlots/Makie.jl/issues/1343

Given your comment https://github.com/fonsp/Pluto.jl/issues/1822#issuecomment-1013153422 and the fact you are doing a big refactor right now, I thought I bring this up in this repo here as well.

greimel avatar Apr 15 '22 10:04 greimel

Is this also the reason why I see in the new docs build of https://github.com/Ferrite-FEM/FerriteViz.jl/pull/70 only one plot? https://ferrite-fem.github.io/FerriteViz.jl/previews/PR70/tutorial/

koehlerson avatar Apr 29 '23 10:04 koehlerson

I think this is an initialization order issue. In the PR linked by Max I could track down an error being thrown here https://github.com/SimonDanisch/JSServe.jl/blob/master/docs/javascript/JSServe.bundled.js#L3304-L3307 , because the session for the second plot assumes that some tracking only object is already present in the GLOBAL_OBJECT_CACHE, which should is loaded by the first plot. However, the second plot usually fetches the binary first and hence executes init_session before the first plot has been been able to fetch its binary. Which makes sense, because the binary of the first object is larger due to the some stuff being cached there.

I have tried to resolve this but can not come up with a good solution.

Edit 1: Note that adding barriers won't fix the issue, because modern browsers execute the individual scripts asynchronously... I.e.

<div data-jscall-id="1">
      <script type="module">
        var msgs = await JSServe.fetch_binary('../ac4bca5ca7a63a3c43a9f9ea20a15f7fdc1b0866-2501377904336721166.dist');
        JSServe.init_session('6478f46f-956e-43aa-89f8-bdb93696fa7d', msgs, 'sub');
      </script>
      <canvas data-jscall-id="2" tabindex="0"></canvas>
    </div>
<div data-jscall-id="3">
      <script type="module">
        var msgs = await JSServe.fetch_binary('../66b9681ba3555ad76ef7104ea0663387f8412de3-18296366943194903786.dist');
        JSServe.init_session('2b7f892c-dcc2-4e7a-ad98-c549d1e5d781', msgs, 'sub');
      </script>
      <canvas data-jscall-id="4" tabindex="0"></canvas>
    </div>

also does not fix the issue.

termi-official avatar May 22 '23 16:05 termi-official

The new JSServe release should fix the issue (at least it does for us). Can you take a look if you have time Fabian?

termi-official avatar May 23 '23 15:05 termi-official

Unfortunately not. Now there is not even a single plot anymore :-(

image

greimel avatar May 23 '23 20:05 greimel

I think in the new version you have to remove exportable=true, offline=true and just call Page() - at least it is my understanding that JSServe handles the setup now more automatically.

termi-official avatar May 23 '23 21:05 termi-official

Well, I dont think this was necessarily the same issue ... Pluto's export is doing quite a lot of things, so lots of ways to break ... I think we'll need to sit down and debug the issue in Pluto at some point, but it hasn't been a priority yet..

SimonDanisch avatar May 23 '23 21:05 SimonDanisch

I can not even reproduce this locally, because I am unable to install version 2.2.3. Weird.

termi-official avatar May 23 '23 21:05 termi-official