Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception thrown when WGLMakie containing element is removed #4342

Open
frankier opened this issue Sep 10, 2024 · 0 comments · May be fixed by #4343
Open

Exception thrown when WGLMakie containing element is removed #4342

frankier opened this issue Sep 10, 2024 · 0 comments · May be fixed by #4343
Labels
bug WGLMakie This relates to WGLMakie.jl, the Web-based WebGL backend for Makie.

Comments

@frankier
Copy link
Contributor

If we remove the element containing WGLMakie before its initailsed there is an exception:

using HTTP
using Bonito: App
using Makie
using WGLMakie


function main()
    HTTP.listen() do http::HTTP.Stream
        HTTP.setstatus(http, 200)
        HTTP.startwrite(http)
        write(http, "<html><body>")
        write(http, "<h1>Bonito element removal</h1>")
        app = App() do
            sleep(2)
            fig = Figure()
            return fig
        end
        io = IOBuffer()
        show(io, "text/html", app)
        body = take!(io)
        write(http, "<div id=\"bonito\">")
        write(http, body)
        write(http, "</div>")
        write(http, "<script>setTimeout(() => {document.getElementById('bonito').remove()}, 1000);</script>")
        write(http, "</body></html>")
    end
end

if abspath(PROGRAM_FILE) == @__FILE__
    main()
end

The exception is:

An exception was thrown in JS: TypeError: Cannot read properties of null (reading 'getContext')
Additional message: error initializing scene
Stack trace:
    TypeError: Cannot read properties of null (reading 'getContext')
        at threejs_module (http://localhost:9385/assets/435ec4531f8729b0dfad48036f91f9e1eab0aa39-wglmakie.bundled.js:23033:26)
        at Module.create_scene (http://localhost:9385/assets/435ec4531f8729b0dfad48036f91f9e1eab0aa39-wglmakie.bundled.js:23099:22)
        at eval (eval at <anonymous> (http://localhost:9385/assets/f1a88e34853c38ba45791ee4149df30a0c07525a-Bonito.bundled.js:3561:27), <anonymous>:5:30)
┌ Warning: error while processing received msg
│   exception =
│    Three object should be ready after init, but isn't - connection interrupted? Session: Session{Bonito.WebSocketConnection}:
│      id: 9d871a24-7426-425e-98a3-946845037797
│      parent: Nothing
│      connection: open
│      isready: true
│      asset_server: Bonito.ChildAssetServer
│      queued messages: 0
│    , initialized: false

But there could be legitimate reasons to have this happen, e.g. plot shown in a model element that the user immediately closes.

@frankier frankier added the bug label Sep 10, 2024
@frankier frankier linked a pull request Sep 10, 2024 that will close this issue
7 tasks
@ffreyer ffreyer added the WGLMakie This relates to WGLMakie.jl, the Web-based WebGL backend for Makie. label Sep 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug WGLMakie This relates to WGLMakie.jl, the Web-based WebGL backend for Makie.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants