Repository navigation
Description
Problem
A live-brush preview writes cube data to its target layers with a new write number (fvNextWriteSeq, runtime/delta.js). A response that lands during the brush carries an older number, so the target layers refuse it. When the brush is abandoned, _fvCubeGestureAbort (plotly/events.js) puts back the data from before the drag, together with its number. The refused response is not recovered.
Result: the target shows old data under its current viewport. No request is pending that can correct it, so it stays wrong until a later interaction re-aggregates that figure.
This is not new. main gives the same result: there, the response overwrote the preview, and the abort then put back the data from before the drag. PR #89 fixes the other order: a response that lands after the abort now applies.
Reachability
Reproduced in a browser (test below). The case needs a pending response and an abort after live frames. The aborts are safety paths:
- An edit drag of an existing box, when Plotly emits no
plotly_selectedwithin_FV_SELECTION_EDIT_ABORT_MS(1.5 s). - A deselect during the drag.
- An empty
plotly_selected.test_abandoned_gesture_restores_targetsnotes that headless Plotly 3 has no reliable mouse trigger for it, so the test emits it by hand.
The case is most likely on a slow source, where a zoom response is still pending when the user starts a brush.
Repro
Two-histogram cube dashboard, live_brush="auto":
- Zoom the target histogram to [20, 60]. Hold its response.
- Start a live brush on the source histogram. Wait until the target shows the preview.
- Release the zoom response. The target refuses it.
- Abandon the brush with an empty
plotly_selected.
Expected: the target bins lie inside [20, 60] (the zoom response).
Actual: the full-range bins from before the drag (centers 4.2 to 95.6) under the [20, 60] axis.
Browser test for tests/test_browser_cube.py (uses the helpers from PR #89)
def test_abandoned_gesture_keeps_a_response_that_landed_during_it(
self, page: Page, server_port: int
):
url = _two_hist_dashboard_url(server_port, "_cube_browser_abandon_during", "auto")
page.goto(url)
_wait_for_init(page, "plotly")
page.evaluate(_COUNT_SETTLED_UPDATES)
_enter_select_mode(page)
held = _hold_first_update(page)
page.evaluate("() => Plotly.relayout(divs[1], {'xaxis.range': [20, 60]})")
_wait_held(page, held)
y_before = _target_y(page)
x1, x2, y, _width = _drag_coords(page)
page.mouse.move(x1, y)
page.mouse.down()
page.mouse.move((x1 + x2) / 2, y, steps=8)
page.wait_for_function(
"""(yBefore) => {
const ys = Array.from(divs[1].data[0].y || []);
return ys.length > 0 && JSON.stringify(ys) !== JSON.stringify(yBefore);
}""",
arg=y_before,
timeout=10_000,
)
_release(page, held, settled=1) # the preview holds the target: refused
page.evaluate("divs[0].emit('plotly_selected', undefined)")
page.wait_for_timeout(500)
centers = page.eval_on_selector("#fv-plot-1", "gd => Array.from(gd.data[0].x)")
assert 20 <= min(centers) and max(centers) <= 60, centersIt fails on the PR #89 branch with assert (20 <= 4.1583333333375).
Fix direction
Two options:
- Keep refused responses in the saved state. When a live preview refuses a response that is newer than the saved pre-drag data,
_fvClaimSlotstores the response in the saved state. The abort then puts back the response. This is about 20 lines indelta.js, plus a registry of saved slots that a commit clears. It covers a request sent before the brush, which is the realistic order. A request sent during the brush is still lost: its response is accepted, and the abort then overwrites it. - Keep previews out of the layer slots. Previews go to a separate preview layer that the renderer reads first. A commit copies the preview into the slots with a new number. An abort drops the preview. Server responses then always follow the normal order rule, and the save and restore code (
fvSaveLayerData,fvSaveHasBackground) goes away. This is complete. It touches the cube live-brush path, the renderer reads inbuildTracesForFigure, and the cube reads of recorded child results inruntime/cube.js.
Option 2 is preferred when the cube live-brush path next changes. The fix also removes the ponytail: note above fvSaveLayerData, which describes this limitation.
Activity