Skip to content

fix(whiteboard): prevent crash when slide changes while a viewer is editing - #25345

Merged
ramonlsouza merged 1 commit into
bigbluebutton:v3.0.x-developfrom
imdt-claudiop:fix/whiteboard-editing-shape-crash-25332
Jun 30, 2026
Merged

ramonlsouza merged 1 commit into
bigbluebutton:v3.0.x-developfrom
imdt-claudiop:fix/whiteboard-editing-shape-crash-25332

Conversation

@imdt-claudiop

@imdt-claudiop imdt-claudiop commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

What's happening

When multi-user whiteboard is on and a viewer is actively editing a text/shape (mid-interaction, before committing), a presenter changing the slide used to crash the viewer's whiteboard with Expected an editing shape!. Only the editing viewer was affected; everyone else was fine, and the viewer could recover by minimising and restoring the presentation panel.

Closes #25332

Why it crashes

The [curPageId] effect in component.jsx handles slide changes by mutating the tldraw store: it removes shapes that belong to the old page (cleanupStore), switches the current page (setCurrentPage), and clears history — all inside one batch. The problem: it does this without first taking the editor out of the select.editing_shape state. So the shape being edited gets removed from under the editor while the state machine is still parked in editing_shape with a dangling editingShapeId. The viewer's next pointer-down then calls getEditingShape(), gets undefined, and tldraw throws Expected an editing shape! — which trips the error boundary and shows the recovery dialog.

The fix

Exit the editing interaction before the store mutation:

// component.jsx, top of the [curPageId] effect, before cleanupStore/setCurrentPage
if (tlEditorRef.current.getEditingShape()) {
  tlEditorRef.current.complete();
}

complete() dispatches the complete event → EditingShape.onComplete → the parent state node transitions to idle → onExit runs and clears editingShapeId cleanly, while the shape still exists. This mirrors the approach PR #21727 took for the same class of bug in hooks.js (setEditingShape(null) alone doesn't leave the editing_shape state node, so the next pointer-down still throws — complete() does).

The guard on getEditingShape() is deliberate: without it, an unconditional complete()/tool reset would also fire on a plain slide change and reset the presenter's active tool. With the guard, a normal slide change (no active edit) is completely unaffected.

Behavioural note (intentional)

When the presenter changes the slide while a viewer is mid-edit, the in-progress (uncommitted) annotation on the old slide is discarded. This is expected: the slide change destroys the old page's editable surface anyway, so the annotation couldn't have been committed regardless. The alternative (auto-committing partial edits on slide change) would land half-finished text/shapes on the board, which is worse.

Second callsite

There's another editor.setCurrentPage(...) in handleTldrawMount (~L1567). It runs only at mount time, when no interactive edit can exist yet (the editor was just constructed), so guarding it would be dead code. Left unguarded on purpose.

Non-regression test

New e2e test bigbluebutton-tests/playwright/whiteboard/slideChangeWhileEditing.ts (registered in whiteboard.spec.ts):

  • Enables multi-user whiteboard, viewer enters editing_shape (text tool → click canvas → type — without clicking away, which would commit and leave the editing state).
  • Deterministic precondition: waits for both wbTextTrue and wbEditingTextArea (the textarea tldraw only renders while actively editing), so the test never races the slide change against an edit that hasn't actually entered editing_shape.
  • Registers a pageerror listener on the viewer page (the one that crashes), then the presenter advances the slide.
  • Probes a few pointer-downs on the viewer's canvas (the exact gesture that used to throw).
  • Asserts zero Expected an editing shape errors and that the whiteboard stays mounted.

Red-then-green proof

  • Red (pre-fix bundle 0f013afd): the test fails — the viewer pageerror is captured (6 errors), the whiteboard falls into the "Reset data" recovery dialog, slide content is gone.
  • Green (fixed bundle db1253f): 2 passed (24s), same sequence, 0 errors, clean Page 2, whiteboard mounted.

The existing Skip slide regression test also continues to pass.

Visual evidence

Each MP4 below is the full repro sequence (~30s, low-res to keep the upload small). The same scripted flow runs against the pre-fix bundle (crash) and the fixed bundle (no crash).

Timeline of what to look for in each MP4:

  • 0:00–0:18 — presenter enables multi-user whiteboard; viewer picks the text tool, clicks the canvas and types "Hello" (the viewer is now in editing_shape).
  • ~0:18 — presenter advances to the next slide (the [curPageId] effect fires on the viewer).
  • 0:18–0:30 — viewer's next pointer-downs on the canvas.
Before (pre-fix) After (fix)
Viewer hits the tldraw "Reset data" recovery dialog (Expected an editing shape! crash); slide content gone. Same sequence: whiteboard cleanly mounted on Page 2, no error.
Before: crash After: no crash

Click either GIF to open the full MP4 with controls.

…diting

When the presenter changed the slide while a viewer was mid-edit on the
whiteboard (select.editing_shape), the [curPageId] effect mutated the tldraw
store (cleanupStore + setCurrentPage) and removed the shape being edited
without first taking the editor out of editing_shape. The editor was left
with a dangling editingShapeId, so the viewer's next pointer-down hit
tldraw's "Expected an editing shape!" assertion and tripped the error
boundary.

Commit the in-progress edit via editor.complete() before the store mutation
so tldraw runs EditingShape.onExit while the shape still exists. The call is
guarded by getEditingShape() so a normal slide change (no active edit) never
resets the presenter's current tool.

Add a Playwright regression test (extends MultiUsers) that drives the race
and asserts the viewer never throws "Expected an editing shape!" and the
whiteboard stays mounted.

Fixes bigbluebutton#25332
@coderabbitai

coderabbitai Bot commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

In component.jsx, the slide-change useEffect now calls getEditingShape() and, if a shape is actively being edited, invokes complete() before executing cleanupStore, setCurrentPage, and finalizeStore. This prevents a dangling editingShapeId from surviving the store mutation, which previously caused a crash on the next pointer-down. A new Playwright regression test (SlideChangeWhileEditing) captures viewer page errors, initiates a mid-edit text shape as a viewer, advances slides from the presenter, and asserts that the "Expected an editing shape!" error does not occur and the whiteboard remains mounted.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • GuiLeme
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the crash fix for slide changes during active whiteboard editing.
Linked Issues check ✅ Passed The code and new test address issue #25332 by exiting edit mode before slide cleanup and verifying no crash.
Out of Scope Changes check ✅ Passed The changes stay focused on the crash fix and regression test, with no clear unrelated additions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed The description matches the code changes and regression test, explaining the slide-change editing crash and its fix.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sonarqubecloud

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@bigbluebutton-tests/playwright/whiteboard/slideChangeWhileEditing.ts`:
- Around line 41-50: The text-entry step in slideChangeWhileEditing is still
racing the editor mount because keyboard.type('Hello') runs before the editing
textarea is guaranteed to exist. In slideChangeWhileEditing, wait for
e.wbEditingTextArea to be present before typing, then keep the existing checks
for e.wbTextTrue and e.wbEditingTextArea after the input to confirm the editor
entered the expected state.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: d564d768-543f-4c05-aeaa-a0fde4741f2c

📥 Commits

Reviewing files that changed from the base of the PR and between 5e0e174 and 72e5511.

📒 Files selected for processing (4)
  • bigbluebutton-html5/imports/ui/components/whiteboard/component.jsx
  • bigbluebutton-tests/playwright/core/elements.ts
  • bigbluebutton-tests/playwright/whiteboard/slideChangeWhileEditing.ts
  • bigbluebutton-tests/playwright/whiteboard/whiteboard.spec.ts

Comment on lines +41 to +50
await this.userPage.page.mouse.click(textX, textY);
await this.userPage.page.waitForTimeout(300);
await this.userPage.page.keyboard.type('Hello');

// Deterministic precondition: the text shape exists (wbTextTrue) AND the editor
// is actively editing it (tldraw only renders the editing textarea while
// isEditing is true). Asserting both avoids racing the slide change against an
// edit that has not actually entered editing_shape yet.
await this.userPage.hasElement(e.wbTextTrue, 'viewer should have a text shape with content');
await this.userPage.hasElement(e.wbEditingTextArea, 'viewer should be actively editing the text shape');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Locate the test and the helper methods it relies on.
git ls-files | rg '^bigbluebutton-tests/playwright/whiteboard/slideChangeWhileEditing\.ts$|^bigbluebutton-tests/playwright/.*\.ts$' >/tmp/files.txt
printf '--- candidate files ---\n'
cat /tmp/files.txt

printf '\n--- outline: slideChangeWhileEditing.ts ---\n'
ast-grep outline bigbluebutton-tests/playwright/whiteboard/slideChangeWhileEditing.ts --view expanded || true

printf '\n--- search for wbEditingTextArea and hasElement definitions/usages ---\n'
rg -n "wbEditingTextArea|hasElement\\(" bigbluebutton-tests/playwright -S

printf '\n--- relevant file excerpt ---\n'
nl -ba bigbluebutton-tests/playwright/whiteboard/slideChangeWhileEditing.ts | sed -n '1,120p'

Repository: bigbluebutton/bigbluebutton

Length of output: 256


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Show the target file and helper definitions with line numbers.
echo '--- target file ---'
nl -ba bigbluebutton-tests/playwright/whiteboard/slideChangeWhileEditing.ts | sed -n '1,140p'

echo
echo '--- wbEditingTextArea / hasElement references ---'
rg -n "wbEditingTextArea|hasElement\\(" bigbluebutton-tests/playwright -S

echo
echo '--- outline: target file ---'
ast-grep outline bigbluebutton-tests/playwright/whiteboard/slideChangeWhileEditing.ts --view expanded || true

Repository: bigbluebutton/bigbluebutton

Length of output: 225


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '--- target file ---'
sed -n '1,140p' bigbluebutton-tests/playwright/whiteboard/slideChangeWhileEditing.ts

echo
echo '--- wbEditingTextArea / hasElement references ---'
rg -n "wbEditingTextArea|hasElement\\(" bigbluebutton-tests/playwright -S

echo
echo '--- file list for helper targets ---'
git ls-files bigbluebutton-tests/playwright | rg 'whiteboard|helper|page|util|common'

Repository: bigbluebutton/bigbluebutton

Length of output: 50384


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '--- hasElement implementation(s) ---'
rg -n "async hasElement|hasElement\\(" bigbluebutton-tests/playwright -g '!**/node_modules/**' -g '!**/dist/**' -S | head -n 80

echo
echo '--- elements definitions for wbEditingTextArea / wbTextTrue ---'
rg -n "wbEditingTextArea|wbTextTrue" bigbluebutton-tests/playwright/core bigbluebutton-tests/playwright -S | head -n 40

echo
echo '--- likely base class files ---'
git ls-files bigbluebutton-tests/playwright | rg '(^bigbluebutton-tests/playwright/(core|user)/.*\.ts$|elements\.ts$|util\.ts$)'

Repository: bigbluebutton/bigbluebutton

Length of output: 16468


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '--- core/page.ts outline ---'
ast-grep outline bigbluebutton-tests/playwright/core/page.ts --view expanded || true

echo
echo '--- core/page.ts relevant excerpt ---'
sed -n '1,260p' bigbluebutton-tests/playwright/core/page.ts

echo
echo '--- hasElement / waitAndClick usages in core and whiteboard helpers ---'
rg -n "async hasElement|hasElement\\(|waitAndClick\\(" bigbluebutton-tests/playwright/core bigbluebutton-tests/playwright/whiteboard -S

Repository: bigbluebutton/bigbluebutton

Length of output: 25169


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '--- hasElement implementation ---'
sed -n '340,380p' bigbluebutton-tests/playwright/core/page.ts

echo
echo '--- waitAndClick implementation ---'
sed -n '312,334p' bigbluebutton-tests/playwright/core/page.ts

echo
echo '--- Frame.hasElement implementation ---'
sed -n '520,545p' bigbluebutton-tests/playwright/core/page.ts

Repository: bigbluebutton/bigbluebutton

Length of output: 3136


Wait for the editing textarea before typing. The 300ms sleep still leaves keyboard.type('Hello') racing the mount of e.wbEditingTextArea; the later hasElement() checks only assert the state after the fact. Gate the typing step on the textarea first.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@bigbluebutton-tests/playwright/whiteboard/slideChangeWhileEditing.ts` around
lines 41 - 50, The text-entry step in slideChangeWhileEditing is still racing
the editor mount because keyboard.type('Hello') runs before the editing textarea
is guaranteed to exist. In slideChangeWhileEditing, wait for e.wbEditingTextArea
to be present before typing, then keep the existing checks for e.wbTextTrue and
e.wbEditingTextArea after the input to confirm the editor entered the expected
state.

@github-actions

Copy link
Copy Markdown

✅ Automated tests have passed!

@ramonlsouza
ramonlsouza self-requested a review June 30, 2026 11:02
@ramonlsouza ramonlsouza added this to the Release 3.0 milestone Jun 30, 2026
@ramonlsouza
ramonlsouza merged commit b177871 into bigbluebutton:v3.0.x-develop Jun 30, 2026
34 checks passed
@ramonlsouza ramonlsouza mentioned this pull request Jul 1, 2026
8 tasks done
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.

Whiteboard error when using multiuser

2 participants