Skip to content

feat: draw the gl3d pick pass on demand - #8

Draft
katosh wants to merge 7 commits into
mainfrom
pr/gl3d-pick-v2
Draft

katosh wants to merge 7 commits into
mainfrom
pr/gl3d-pick-v2

Conversation

@katosh

@katosh katosh commented Dec 5, 2026 •

Copy link
Copy Markdown

Description

A 3D scene draws all its objects a second time, for hover, in each frame that moves the camera. This PR draws that pick pass only when a pointer event queries it. With 2 million glyph markers, a rotation frame takes 31.2 ms against 45.2 ms on main, with 10 draw calls against 20. The change is not opt-in.

Bar chart: 20 draw calls for each rotation frame before and 10 after, 10.5 for each pointer move before and 0 to 1 after
Draw calls for each rotation frame and each pointer move, main against this branch. Ten traces, 100,000 glyph markers, thus 10 calls draw the scene one time. Headless Chromium on ANGLE Metal.

Nothing reads the pick buffer while a button is down. The new gl-plot3d draws the pass at the first pointer query after a change, or 120 ms after the last frame. A scene where all traces have hoverinfo: 'skip' draws none.

AnnZarro draws millions of cells with plotly.js, and found this cost.

Changes

Behavior changes:

  • scene.hovermode: false emits no plotly_hover and no plotly_unhover. A button press still gives plotly_click.
  • The axis spikes do not move to a marker with hoverinfo: 'skip'
  • With the axis spikes off, a hover draws no frame, and hover events come one time for each pointer event

Testing

  • 10 new specs in gl3d_hover_click
  • Suites to run: gl3d_hover_click, gl3d_plot_interact, gl3dlayout, scatter3d
  • 49 frames and the events of 14 pointer sequences are identical to main

Notes

  • If feat: add an opt-in preview for scattergl and scatter3d plots of many points #10 merges first, one gl3d_lod spec needs a change, because the full frame after the settle then draws no pick pass. The change is ready.
  • A pointer event right after a frame that moves the camera gets a pass of that frame. On main it gets the picture of the frame before.
  • After a camera change, the first pointer query draws the pick pass inside the pointer handler. Thus that hover or click waits for one pass. With visible axes at 50M disc markers, the release after a rotation took 265 ms against 181 ms. These are medians of 9 releases, with ranges of 202 to 445 ms and 138 to 229 ms. A follow-up can draw the pass ahead of the query.
  • At 50M disc markers with visible axes, a rotation step took 250 ms against 272 ms, with 0 pick draws against 400. With hidden axes it took 207 ms against 260 ms, and 259 ms with pickMode: 'eager'.
  • A hover gains only with the axis spikes off. With hidden axes, a hover at 50M disc markers redraws no trace instead of 10. It took 48 ms, the floor of our test harness, against 118 ms. With visible axes, the two redraw the traces, and a hover took 99.6 ms against 99.2 ms.
  • The 50M times compare pr/all with the typed-position branch feat: keep typed scatter3d positions flat and on the GPU #7, one run each

We can split this PR, drop a behavior change, or add the follow-up. Thank you for your time.

Checklist

  • The linked issue has the ready-for-pr label, and it has no assignee or lists me as an assignee
  • I opened the pull request from a branch other than main in my fork
  • I selected "Allow edits from maintainers"
  • I did not edit files in dist/
  • I committed package-lock.json only for a dependency change
  • I added a file to draftlogs/ as draftlogs/README.md describes, or I will add one after the pull request opens

…anches

The scene drew its pick buffer in each frame that moved the camera. The
new gl-plot3d draws the buffer when a pointer event queries it, and draws
none if no object permits a pick. stackgl_modules/index.js is the webpack
output of the pinned commits. The pins go away when the gl-vis pull
requests merge and release.
A scatter3d trace with hoverinfo skip tells the scene that no pointer
event can select it. A scene with hovermode false queries the pick buffer
only on a button press and emits no hover events. A trace with more
points than the 24 bits of a pick id gets no hover and no click, because
its ids name other points.
…before the first frame of a trace

Two specs compare a run whose hover events come from the frame with a run whose events come from the pointer handler. They waited 60 ms after each pointer event, and on a slow runner the frame came later, so the frame run lost its last events. They now wait for the frame.

The new spec sends a pointer event in the task in which newPlot resolves. It needs the gl-plot3d commit that draws no pick pass on demand before the frame that draws a change. The pin of that commit follows.
The pinned commit draws no pick pass on demand while a change waits for its frame, and queries no pick buffer before a pass has drawn it. Without it, a pointer event between scene.add and the next frame gave a hover label for a trace that no frame had drawn. The stackgl bundle is the webpack output for the pin.
plotly draws the first frame of a scene inside newPlot, so the event of the spec comes right after that frame, not before it. The spec text said otherwise.
The pinned commit gives a pick pass on demand 1 ms after a frame that changed the scene, as the read-back of the frame pass did. A pointer event right after the first frame of a scene finds nothing again, so a pointer that rests on a scene gets no hover label until it moves. The stackgl bundle is the webpack output for the pin.
…objects

The pinned commit gives no pick pass on demand for 1 ms after the first frame that follows scene.add or scene.remove, as the read-back of the frame pass did. A pointer that rests on a scene when it appears gets no hover label until it moves, as before. The pins of the two commits before this one made the wait too wide: it also ran after each frame of a moving camera, and hover specs failed at random. The stackgl bundle is the webpack output for the pin.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant