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

Designer rendering research/prototyping #298

Open
Tracked by #275
luxaritas opened this issue Dec 12, 2022 · 4 comments
Open
Tracked by #275

Designer rendering research/prototyping #298

luxaritas opened this issue Dec 12, 2022 · 4 comments
Assignees
Labels
scope: designer-hud RNA designer user interface type: enhancement New feature or request

Comments

@luxaritas
Copy link
Member

Due to the complexity of interoperation between canvas and DOM, we want to explore the viability of an SVG-based 2D RNA visualization. In particular, there are concerns around the performance of animations with large numbers of bases.

NB: We probably still have to deal with Canvas for RNA3D, which means we probably still need to think through how interop needs to work.

@luxaritas luxaritas self-assigned this Dec 12, 2022
@luxaritas luxaritas added scope: rna-vis RNA visualizations type: enhancement New feature or request labels Dec 12, 2022
@luxaritas luxaritas changed the title RNA2D performance prototyping RNA2D rendering research/prototyping Dec 12, 2022
@luxaritas
Copy link
Member Author

After doing some research, it looks like SVG starts to break down around 1000 elements, which is quite low in our case. I'll probably want to start looking at other options for WebGL/DOM integration as it seems like we may not have much of a choice

@luxaritas luxaritas changed the title RNA2D rendering research/prototyping Designer rendering research/prototyping Dec 13, 2022
@luxaritas
Copy link
Member Author

Ultimately this isn't an issue specific to RNA2D - it affects RNA3D as well, and really doesn't have much to do about the performance of RNA2D itself at this point (since we've determined SVG won't cut it) but more generally handling interlaced HTML/WebGL content.

I started looking into this, and found a few resources:

Eventually I stumbled across https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas#synchronous_display_of_frames_produced_by_an_offscreencanvas - this shows a pattern of using OffscreenCanvas.transferToImageBitmap and a canvas with a bitmaprenderer context, which is supposed to allow for transferring image data without a readback from the GPU to CPU. Now Safari doesn't support OffscreenCanvas, but createImageBitmap can create an ImageBitmap directly from a regular WebGL canvas, which should have the same benefits.

I used a modified version of the PixiJS Bunny Mark application to test this out, and with 10k bunnies, splitting the image across 16 canvas elements:

  • Chrome stays at 60fps
  • Webkit drops from 60 to ~40
  • Firefox drops from ~55 to ~10 😞

Turns out, Firefox incurs readbacks when generating ImageBitmaps. There's an open bug for createImageBitmap and one for OffscreenCanvas.transferToImageBitmap.

@luxaritas luxaritas added scope: designer-hud RNA designer user interface and removed scope: rna-vis RNA visualizations labels Dec 13, 2022
@luxaritas
Copy link
Member Author

I'm throwing this under designer-hud since at this point I'm considering this largely in terms of its impact with the windowing system

@luxaritas
Copy link
Member Author

Investigating virtual-webgl gave me the idea that maybe passing the webgl canvas to a Context2D's drawImage would work instead, but same problem exists there, with a related open bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1163426

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: designer-hud RNA designer user interface type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant