Repository navigation
Conversation
The outline of a glyph marker draws only when lineWidth is above 0, but gl-scatter3d built its vertices for every point. Count and fill them only when lineWidth is above 0. A circle marker drops from 104 to 60 vertices.
A circle marker is a vectorized glyph mesh of 60 to 104 vertices, about 4,160 bytes in the vertex buffers. With scene.markerrender set to disc or auto, circle and circle-open markers draw as one gl.POINTS vertex with a round cutout in the fragment shader, with an outline ring for marker.line.width. Other symbols, projections on the axes and sprites larger than the point size limit keep the glyph path. The default is glyph, so rendering does not change unless the attribute is set. gl-scatter3d is pinned to a fork commit, and stackgl_modules/index.js is rebuilt from it.
_relayout set flags.calc when a relayout altered the range of an axis in a constraint group. For regl traces, each zoom step then recalculated every trace and uploaded every point again. The replot applies the constraints from the axes. Only an autorange needs the extremes of a new calc. The relayout now sets flags.plot, if every trace is a regl trace and every axis of the group has a fixed range.
…ansparency The forks add an optional pass that blends translucent objects by depth. Nothing changes until a scene turns it on. Rebuild stackgl_modules/index.js with npm run bundle-stackgl.
Translucent markers blend in draw order, so the last trace lies on top from every camera angle. With scene.oit set to auto, the markers blend by depth and the draw order has no effect. The default is off and keeps the existing pass and pixels. The scene reports the result with getOITStatus() and the plotly_oitstatus event.
The fork skips objects with alwaysOnTop in the depth, opaque and transparent passes and draws them after the composite. Rebuild stackgl_modules/index.js with npm run bundle-stackgl.
Points in front hide a highlighted marker inside a dense cloud. The markers of a trace with alwaysontop true draw last, over everything else, with no depth test. The default is false and changes no pixel. The markers stay pickable.
…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.
The next commits pass Float32Array data to regl-scatter2d without a copy. The pinned commit holds the changes that regl-scatter2d needs for that, and a built bundle.js. regl-scatter2d builds bundle.js at publish time, so a plain git commit holds no entry file. A regl-scatter2d release replaces this pin.
calc wrote x and y of each trace to a plain Array of doubles and built an Array of point ids. regl-scatter2d then copied the positions and uploaded 16 bytes for each point. Each restyle or moveTraces repeated the copies and the upload.
For a markers-only trace on linear axes with Float32Array data, calc now passes {x, y, count, rev} to regl-scatter2d. regl-scatter2d uploads 8 bytes for each point one time. The same buffer range with the same layout.datarevision is the same data. calc reads the axis extremes from a cache and builds the point ids at the first read.
If you refill a typed array in place, set a new layout.datarevision.
calc built a point-cluster tree for each trace of 100,000 points or more, at every calc. Only hoverPoints reads the tree. If layout.hovermode is false, or the trace has hoverinfo 'skip', the first read now builds the tree. With hover, calc builds the tree as before.
The value disc draws a glyph where a disc cannot draw the marker, and auto is the same as disc for now. The first description left both out.
The new gl-scatter3d takes positions as one Float32Array and keeps its position buffer when the caller sends no positions. stackgl_modules/index.js is the webpack output of the pinned commit. The pin goes away when the gl-vis pull request merges and releases.
A scatter3d trace made one small array for each point, also for typed x, y, and z. Each plot call scanned the data three times and uploaded all positions again, also for a color change of one trace. Typed data of a trace with markers only, on linear axes, now converts to one Float32Array. The scene scans the data one time for the bounds. A later plot call with the same buffer ranges, scale, and layout.datarevision sends no positions.
…aces A scene scales its data by the extent of the visible traces. A trace that the legend hides or shows can change that extent, and then every other trace converts and uploads its positions again. With datascale 'all', legendonly traces count for the scale, so the other traces keep their positions on the GPU. The default, 'visible', does not change.
Each graph with a regl trace created two WebGL contexts. In scattergl and splom graphs, the focus layer shows only the selected points. Most graphs never select, but the browser counts the second context against its limit of about 16 for each page. prepareRegl now creates the context of the focus layer on request, or if the graph has parcoords. scattergl sends the request when a selection drag mode starts, or when the first selection draw comes. The selected points appear on the focus layer as before.
Both branches pass the pick option to gl-scatter3d. One call of neverPicked now decides the kept positions and the pick option.
The combined branch needs every package change at one time. gl-plot3d, gl-scatter3d, and regl-scatter2d point at the all branches of the forks.
npm prepares a git dependency that has a build script. It installs the devDependencies of regl-scatter2d, which include the native gl package, and a plain npm ci fails where gl has no binary. The new pinned commit holds the same bundle.js and no build script, so npm ci needs no build.
The other draftlog files start with the dash.
…ositions Only the combined branch drops the stored positions of such a trace, because one call decides the pick option and the kept positions.
The branch restores the description of scene.markerrender and fixes its draftlog. The combined draftlog already holds the fix.
A preview of every k-th marker had one k-th of the cover of the full picture, so faint markers all but vanished in it. A marker of alpha a that stands for k markers now gets the alpha 1 - (1 - a)^k. This is exact where the k markers cover the same pixels, and an estimate elsewhere. A marker of alpha 1 does not change. The change is in the two packages: this commit moves the pins of regl-scatter2d and gl-scatter3d, holds the webpack output for stackgl_modules, and adds one spec for scattergl and one for scatter3d.
The branch adds two specs and moves its pins. The pins of the combined branch follow in the next commit.
gl-scatter3d and regl-scatter2d gained the opacity compensation of a level of detail preview. The stackgl bundle is rebuilt from the new pin.
The order independent passes use their own disc fragment shader. The spec shows that it links with the denser thinned draw and gives about the density of the full picture.
This was referenced Dec 5, 2026
With virtual-webgl, regl gets a virtual context. That context calls functions that virtual-webgl copied from WebGLRenderingContext.prototype at load, so a later spy on that prototype records nothing, and four upload specs failed in the virtual-webgl job. The specs now spy on the prototype of the context itself. Without virtual-webgl, that prototype is WebGLRenderingContext.prototype as before.
virtual-webgl returns an object with constants and no functions for an extension that it does not wrap, also when the context has no such extension. The level of detail tested only that the object exists, and then threw in the timer that draws the full picture in parts. The full picture never came. The extension now counts as missing unless createQueryEXT and getQueryObjectEXT are functions, and the plot waits with readPixels after each part. One spec passes such an object to the scene. The spec was not run on this machine before the commit.
…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 branch counts the uploads on the context that regl uses, so that the upload specs pass with virtual-webgl.
The branch waits with readPixels when the timer query extension has no functions, as with virtual-webgl.
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.
…r the frame of a change The pick pass on demand no longer runs before the frame that draws a change, and no query reads a pick buffer before a pass has drawn it. The stackgl bundle is rebuilt from the new pin.
The branch brings its specs for the frame of a change. The combined branch keeps its own pins and the bundle rebuilt from them.
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.
A pick pass on demand waits 1 ms after the first frame that follows a change of the objects. The frame at the end of scene.plot no longer lets a pointer event pick before that.
The branch brings its specs for a pointer event right after the first frame of a scene. The combined branch keeps its own pins and the bundle rebuilt from them.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
AnnZarro is an open viewer for single-cell data. It draws 1 million to 100 million points with plotly.js. At that size, plotly.js reaches three limits:
Key results
mainRangeError: Invalid typed array length: 624000000RangeError: Invalid typed array length: 1560000000layout.lod(#10 alone): first frame 245 ms, full picture 885 ms, pan frame 5.4 msscene.oit: 'auto')The timings ran on the strict bundle of
fd8cfbb56. Later commits change only the pick pass after an add or a remove, a fallback for a missing timer extension, and tests.Time to the first frame and GPU buffers against the number of points. The red X marks where upstream
mainstops. In 3D, that is aRangeErrorfrom 2M points per trace. In 2D, the tab crashes at 50M points. With #4 alone, the tab crashes at 100M points. Above 16.7M points in one trace, a trace keeps no pick ids, thus it has no hover and holds 12 bytes per point, not 16.Conditions: Apple M3 Max, headless Chromium on ANGLE Metal, 1200 x 800 px. Each plot holds ten traces of opaque markers of size 3 with
Float32Arrayinput, and hover is off in 2D. Each number is one run, unless the cell says median. In 3D, this branch draws discs (scene.markerrender: 'auto'), and upstream draws its default glyph markers. The 2D pairs are strict bundles from one builder. Upstream is plotly.jsmain(df22b38).This branch holds ten pull requests that remove these limits. Each one is opt-in or moves no pixel. We can rework, combine, split, or drop each one. Thank you for your time.
Changes
Each row links a review pull request in our fork. For each one that you want, we open one short issue and one pull request here that closes it.
scaleanchorscene.markerrendermarker.line.widthsets (plotly#3796).scene.oitalwaysontopfor scatter3dFloat32Arrayper trace. An edit that keeps the positions uploads no position.layout.lodandscene.lodscene.oit: 'auto'andscene.markerrender: 'disc'together.pr/disc-oitshows that state.The base of a pull request is upstream
main, or the pull request that it needs.The 3D pull requests pin gl-plot3d and gl-scatter3d to fork commits in
stackgl_modules/package.json. #9 and #10 pin regl-scatter2d the same way. Each package pull request opens with the plotly.js pull request that needs it. This branch pins gl-plot3d70ff6bd, gl-scatter3d213d696, gl-select-static4375784(an override) and regl-scatter2d37e6583. Itsstackgl_modules/index.jsequals a clean rebuild byte for byte.Screenshots/Videos
Conditions for each chart: Apple M3 Max, headless Chromium on ANGLE Metal, 2026-12-04, ten traces, marker size 3, 1200 x 800 px,
Float32Arrayinput. Orange is plotly.js 2.35.3. Green is upstreammain. Blue is this branch (all ten PRs). In a chart of one pull request, "this branch" is that pull request alone.A scatter3d trace of 2,000,000 points does not load (#4 and #7)
Ten scatter3d traces of 2,000,000 points each. Left: upstream
maindraws no point, and we added the box with the error. Right: this branch withscene.markerrender: 'auto'.20 million points in ten traces on this branch. The GIF plays saved frames, thus it shows no frame rate.
Translucent markers blend in trace order (#5, plotly#1267)
Two linked rings of 10,000 points each,
marker.opacity0.2, the same markers on the two sides. Left: upstreammain. Right: #5 withscene.oit: 'auto'.On the left, the last trace covers the other trace at each crossing. The pull request uses 16 depth layers per pixel, thus the result is an approximation, not a sort.
The marker outline (#4, plotly#3796)
marker.line.width1, 2, 4 and 8 at pixel ratio 2, Chrome with ANGLE. Top: upstreammain, 0.93 device pixels at each width. Bottom: #4 withscene.markerrender: 'disc', 1.91 to 15.91 device pixels.Chrome draws each outline 1 device pixel wide today. A disc draws the width that the attribute sets.
A highlight inside a cloud (#6)
One camera loop. On upstream
main, the markers in front cut the ring, and the cut changes with the camera. In the dense cloud, the ring has 0 visible pixels in all 72 frames. Withalwaysontop: true, the full ring shows in each frame.Time for each scenario, 3D (this branch)
Open, rotation frame, recolor, hide and show for 100,000 to 50,000,000 scatter3d points. At opacity 0.5, the blue line also sets
scene.oit: 'auto'.The chart draws one of the four upstream runs at 2,000,000 points, which opened in 3,585 to 4,336 ms.
At opacity 0.5 with
scene.oit: 'auto', a rotation frame of 1,000,000 discs takes 22.6 ms. Upstreammaintakes 24.4 ms for 1,000,000 glyph markers and blends in trace order. The cost grows with the count: 20,000,000 translucent discs take 420 ms for a rotation frame, against 34.7 ms opaque. A translucent rotation at that size needs the level of detail of #10.Time for each scenario, 2D (this branch)
Open, pan frame, recolor, reorder and hide for 1,000,000 to 50,000,000 scattergl points, hover off, no level of detail.
The chart draws a non-strict bundle of upstream
main, which gave 4,316 ms to open and 4,126 ms to recolor 20,000,000 points. With 5,000,000 points and strict bundles, the open takes 117 ms against 974 ms.#2 alone: one pan step with
yaxis.scaleanchorand fixed ranges, median of 10 steps, strict bundles.Single pull requests against upstream
main#4 alone, and #4 with #7: glyphs, discs, and discs with typed positions, 100,000 to 20,000,000 markers.
#9 alone: 20,000,000 points in ten traces,
hovermode: false, strict bundles. The chart names commit a019f22 (source identical to 2441332).#5 alone, the cost: glyph markers at opacity 0.5, strict bundles.
scene.oit: 'auto'draws 41 calls for each rotation frame, not 21.Bytes that go to the GPU, and memory (this branch)
Log scales. "GPU buffers" counts the bytes that the page holds through WebGL, without driver overhead. The memory excludes the input arrays.
A recolor of one scatter3d trace uploads 8,320 MB at 2,000,000 points on upstream
main, and no byte on this branch. A scattergl point needs noArrayBufferbyte, not 32.#4 alone, and #4 with #7: bytes that go to the GPU with 1,000,000 markers, as a count.
Draw calls for a rotation frame and for a pointer move (#8)
#8 alone: a count with ten traces and 100,000 glyph markers. Ten draw calls draw the scene one time.
Level of detail (#10)
The blue lines are #10 alone. The yellow line is this branch (all ten PRs). Preset:
minpoints1,000,000,budget1,000,000,maxstride64,settle150 ms. The stride is 32 at 20M points and 64 at 50M points.With 20,000,000 scattergl points, a pan frame takes 5.4 ms against 114 ms, and the first frame comes after 134 ms against 338 ms. The full picture comes later, after 449 ms against 338 ms, because the full draw starts 150 ms after the last draw request. With 20,000,000 scatter3d points, a rotation frame takes 4.5 ms against 44.2 ms. On this branch, the first 3D frame comes after 316 ms against 1,224 ms with #10 alone. This branch has the typed positions of #7.
Translucent discs with level of detail (#4, #5 and #10 together)
Screencast frames in time order: one scripted rotation drag of 90 steps over 20 million discs in five clouds, without and with
scene.lod. The discs havemarker.opacity0.02, and the scene setsscene.oit: 'auto'. The GIF stops at step 31 of the drag withoutscene.lod. The preview draws every 32nd disc with the opacity of 32 discs. Thus the preview is as dense as the full picture, with more grain. The times in this text come from separate measurement runs.Testing
main. Its text lists the two.main. The 3D ones compare 7 to 49 scenes, and the 2D ones 13 to 61 scenes.mainand with this branch on one machine (macOS). None of the 1,302 images differ. We did not compare the images with the committed baselines. The CI baseline job of this pull request is the authoritative test.'auto'forscene.markerrenderwould move about 52 baselines, thus the default is'glyph'main.scatter3dgl3dlayoutgl3d_hover_clickgl3d_plot_interactscatterglscattergl_selectsplomgl2d_plot_interactplot_apigl3d_lodscattergl_lodmain:scatter3d44 of 44,gl3d_hover_click37 of 39,gl3d_plot_interact43 of 44scattergl51 of 51,scattergl_lod25 of 25,gl3d_lod7 of 7scatterglspec about animation frames ran into its timeout in 1 of 8 runs on earlier states of this branch. We do not know the cause yet.mainon a real GPU. That holds for 61 2D scenes, 14 3D glyph scenes with equal hover ids, and 49 settled 3D frames. The 14 pointer sequences and the scene bounds are equal too.scene.oitwith disc markersscene.lodwith the pick pass on demandscene.oitnpm run lint,npm run typecheckandnpm run test-syntaxpass, andnpm run schema-typegen-diff-checkreports no driftNotes
scene.oit: 'auto'. The branch pr/disc-oit holds that commit.marker.angle, and a size above the point-size limit of the GPUscene.hovermode: false, the scene emits no hover event. We can drop this piece.layout.datarevisionRangeError. Pull requests feat: add scene.markerrender to draw scatter3d circle markers as discs #4 and feat: keep typed scatter3d positions flat and on the GPU #7 lift that limit.scatterglhover is slow above 100k points plotly/plotly.js#8134 (open): scattergl hover is slow above 100k points. The open upstream pull request Fix: Performance for greater than 100k points on hover in scattergl plotly/plotly.js#8198 changes the same hover tree, which limits feat: upload Float32Array data of scattergl traces without a copy #9 with hover on.maingives the same times as plotly.js 2.35.3, within 4 percentmain. Pull request feat: add scene.oit to blend translucent scatter3d markers by depth #5 adds 20,645 bytes, feat: add scene.markerrender to draw scatter3d circle markers as discs #4 adds 10,625, and feat: upload Float32Array data of scattergl traces without a copy #9 adds 5,794. Pull requests feat: create the WebGL context of the focus layer only for selections #1, fix: skip the recalc after a range change of constrained axes of regl traces #2, fix: skip outline vertices of scatter3d markers without an outline #3 and feat: add alwaysontop to scatter3d traces to keep a highlight visible #6 add 40 to 548 bytes each.mainwith the same builder: 63,506 bytes moreChecklist
ready-for-prlabel, and it has no assignee or lists me as an assigneemainin my forkdist/package-lock.jsononly for a dependency changedraftlogs/as draftlogs/README.md describes, or I will add one after the pull request opens