Repository navigation
Fix(html5): Presenter whiteboard camera position moving on window resizing - #24968
Conversation
…a resizes by tracking api-source setCamera calls and dropping the incorrect x/y reposition formula in syncCameraWithPresentationArea
…nt, visual baseline, and zoomed-state preservation after container resize
|
This pull request has conflicts ☹ |
WalkthroughThis PR updates the whiteboard client and adds end-to-end Playwright tests for resize recovery. In the client whiteboard component, zoom-calculation helpers are stored in refs, a per-page actual zoom ratio cache/ref is maintained for presenter-origin camera updates, presenter-side restore now merges only camera.z (no x/y recenter), RAF polling depends on presentation area width/height, and per-page zoom cache is cleaned on unmount. A new exported test class Sequence Diagram(s)sequenceDiagram
participant Presenter
participant Whiteboard
participant Server
participant Viewer
Presenter->>Whiteboard: resize presentation area (moderator action)
Whiteboard->>Whiteboard: recompute baseZoom (refs) and update pageActualZoomRatioRef
Whiteboard->>Server: publish camera update (z, source: api)
Server->>Viewer: broadcast camera update
Viewer->>Whiteboard: receive camera update
Whiteboard->>Whiteboard: compute stored zoom ratio (nextCam.z / baseZoom) and store per-page
Whiteboard->>Whiteboard: apply camera.z only (no x/y recenter for presenter restore)
Note right of Whiteboard: RAF polling reacts to presentationAreaWidth/Height changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
bigbluebutton-tests/playwright/whiteboard/whiteboardResize.ts (2)
63-65: Hard-coded 5 s sleeps will make these tests slow and still flaky.Each method accumulates 10–15 s of
waitForTimeout(mount settle + post-shrink + post-expand), which both slows CI down and still leaves a race with the "35 stable frames + polling" chain mentioned in the comment at Line 114-115 on a slow runner. Consider replacing with an assertion-based wait that polls until the invariant holds (e.g.,await expect.poll(() => getCameraZoom(...), { timeout: 15_000 }).toBeGreaterThan(0)before capturing, and for the post-expand step:await expect.poll(() => getWrapperWidth(...)).toBe(modInitialWidth)). That way the test exits as soon as the layout is settled and only blows up to the timeout on genuine regressions.Also applies to: 107-116, 194-195, 267-268, 279-280
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@bigbluebutton-tests/playwright/whiteboard/whiteboardResize.ts` around lines 63 - 65, Replace hard-coded waitForTimeout sleeps in whiteboardResize tests with assertion-based polling that waits for the actual layout invariants to settle: instead of await this.modPage.page.waitForTimeout(5000) and other sleeps, poll using Playwright expect.poll on helper getters like getCameraZoom(modPage) to be > 0 before taking a capture, and poll getWrapperWidth(modPage) to equal modInitialWidth after expand/shrink. Update all occurrences that sleep (the mount-settle, post-shrink, post-expand waits referenced in the comment) to use expect.poll with a sensible timeout (e.g., 15_000) so the test proceeds as soon as invariants hold and only fails on real regressions.
202-238: React fiber walk is fragile — consider exposing a test hook instead.Walking the fiber tree via
__reactFiber$...to find theuseRefwhose.currenthassetCamera,getCamera, andgetViewportScreenBoundsrelies on React's internal hook memory layout, which is not a stable API.Two realistic breakage sources:
- React 18→19 (or future minor upgrades) can change
memoizedStatestructure or__reactFiber$...naming — documented in past React transitions.- Another component mounting a
useRefwith asetCameramethod would cause the walk to latch onto the wrong ref.A safer approach: expose a narrow test hook (e.g.,
window.__BBB_TEST__.tlEditor = editorRef.currentbehind aNODE_ENV !== 'production'guard) so the test can directly callsetCamerawithout fiber introspection. ThesetEditorprop is already passing the editor to the parent component, making this a straightforward addition.Not a blocker — the current code works and is well-documented. Just flag for future maintenance.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@bigbluebutton-tests/playwright/whiteboard/whiteboardResize.ts` around lines 202 - 238, The test's React fiber walk (searching the DOM node 'whiteboard-element' for keys starting with '__reactFiber' and inspecting hook.memoizedState to find a ref with setCamera/getCamera/getViewportScreenBounds) is fragile; instead, add a narrow test hook in the app code that exposes the editor ref in non-production (e.g., set window.__BBB_TEST__.tlEditor = editorRef.current when setEditor is called or when tlEditorRef is available), then update the test to call window.__BBB_TEST__.tlEditor.setCamera(...) directly; ensure the hook is guarded by NODE_ENV !== 'production' and tied to the existing setEditor/ tlEditorRef so you don't change runtime behavior other than the test-only exposure.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@bigbluebutton-tests/playwright/whiteboard/whiteboardResize.ts`:
- Around line 270-275: The added writes of full-page screenshots into
modShrunkPath and userShrunkPath are dead code because cameraResyncZoomedVisual
never asserts them; either remove the fs.writeFileSync calls for
modShrunkPath/userShrunkPath to avoid wasted I/O, or add explicit Playwright
assertions using toHaveScreenshot (e.g., mirror cameraResyncVisual style) that
reference the corresponding 'mod-whiteboard-resize-zoomed-shrunk' and
'user-whiteboard-resize-zoomed-shrunk' baselines so the shrunk state is actually
validated.
- Around line 252-259: The snapshot files are being saved to hardcoded
platform-specific filenames (modInitialPath, userInitialPath) which can diverge
from Playwright's toHaveScreenshot paths; thread the TestInfo from runResizeTest
into this function and replace the manual path construction
(snapshotDir/mod-whiteboard-resize-zoomed-initial-...png and user-...png) with
calls to testInfo.snapshotPath('mod-whiteboard-resize-zoomed-initial.png') and
testInfo.snapshotPath('user-whiteboard-resize-zoomed-initial.png') before
writing the screenshots returned by this.modPage.page.screenshot() and
this.userPage.page.screenshot(), so the saved baselines match Playwright's
platform-aware snapshot resolution.
---
Nitpick comments:
In `@bigbluebutton-tests/playwright/whiteboard/whiteboardResize.ts`:
- Around line 63-65: Replace hard-coded waitForTimeout sleeps in
whiteboardResize tests with assertion-based polling that waits for the actual
layout invariants to settle: instead of await
this.modPage.page.waitForTimeout(5000) and other sleeps, poll using Playwright
expect.poll on helper getters like getCameraZoom(modPage) to be > 0 before
taking a capture, and poll getWrapperWidth(modPage) to equal modInitialWidth
after expand/shrink. Update all occurrences that sleep (the mount-settle,
post-shrink, post-expand waits referenced in the comment) to use expect.poll
with a sensible timeout (e.g., 15_000) so the test proceeds as soon as
invariants hold and only fails on real regressions.
- Around line 202-238: The test's React fiber walk (searching the DOM node
'whiteboard-element' for keys starting with '__reactFiber' and inspecting
hook.memoizedState to find a ref with
setCamera/getCamera/getViewportScreenBounds) is fragile; instead, add a narrow
test hook in the app code that exposes the editor ref in non-production (e.g.,
set window.__BBB_TEST__.tlEditor = editorRef.current when setEditor is called or
when tlEditorRef is available), then update the test to call
window.__BBB_TEST__.tlEditor.setCamera(...) directly; ensure the hook is guarded
by NODE_ENV !== 'production' and tied to the existing setEditor/ tlEditorRef so
you don't change runtime behavior other than the test-only exposure.
🪄 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: 4687abd1-8b7f-46ea-b3fc-d4d245d627c9
⛔ Files ignored due to path filters (8)
bigbluebutton-tests/playwright/whiteboard/whiteboard.spec.ts-snapshots/mod-whiteboard-resize-initial-Chromium-linux.pngis excluded by!**/*.pngbigbluebutton-tests/playwright/whiteboard/whiteboard.spec.ts-snapshots/mod-whiteboard-resize-shrunk-Chromium-linux.pngis excluded by!**/*.pngbigbluebutton-tests/playwright/whiteboard/whiteboard.spec.ts-snapshots/mod-whiteboard-resize-zoomed-initial-Chromium-linux.pngis excluded by!**/*.pngbigbluebutton-tests/playwright/whiteboard/whiteboard.spec.ts-snapshots/mod-whiteboard-resize-zoomed-shrunk-Chromium-linux.pngis excluded by!**/*.pngbigbluebutton-tests/playwright/whiteboard/whiteboard.spec.ts-snapshots/user-whiteboard-resize-initial-Chromium-linux.pngis excluded by!**/*.pngbigbluebutton-tests/playwright/whiteboard/whiteboard.spec.ts-snapshots/user-whiteboard-resize-shrunk-Chromium-linux.pngis excluded by!**/*.pngbigbluebutton-tests/playwright/whiteboard/whiteboard.spec.ts-snapshots/user-whiteboard-resize-zoomed-initial-Chromium-linux.pngis excluded by!**/*.pngbigbluebutton-tests/playwright/whiteboard/whiteboard.spec.ts-snapshots/user-whiteboard-resize-zoomed-shrunk-Chromium-linux.pngis excluded by!**/*.png
📒 Files selected for processing (3)
bigbluebutton-html5/imports/ui/components/whiteboard/component.jsxbigbluebutton-tests/playwright/whiteboard/whiteboard.spec.tsbigbluebutton-tests/playwright/whiteboard/whiteboardResize.ts
There was a problem hiding this comment.
🧹 Nitpick comments (2)
bigbluebutton-html5/imports/ui/components/whiteboard/component.jsx (2)
1470-1488: De‑duplicate thepageActualZoomRatioRefupdate with the user‑source listener.The new
api/presenter branch here computesbaseZand writespageActualZoomRatioRef.current[pKey] = nextCam.z / baseZusing exactly the same logic as the user‑source listener at Lines 1385‑1394. Consider extracting a small helper (e.g.updateStoredZoomRatio(nextCamZ)) and calling it from both listeners so the ratio formula (and thebaseZ > 0guard) lives in one place. This also makes it easier later if you ever need to harden thebaseZfallback against theHUNDRED_PERCENTsentinel returned bycalculateZoomValueon invalid dimensions — both call sites would get it at once.♻️ Sketch of the helper extraction
+ const updateStoredZoomRatio = (nextCamZ) => { + const baseZ = calculateZoomValueRef.current?.( + currentPresentationPageRef.current?.scaledWidth, + currentPresentationPageRef.current?.scaledHeight, + ); + if (baseZ > 0) { + const pageKey = `${presentationIdRef.current}_${curPageIdRef.current}`; + pageActualZoomRatioRef.current[pageKey] = nextCamZ / baseZ; + } + };Then replace both blocks (user listener around Lines 1385‑1394 and the new api branch) with
updateStoredZoomRatio(nextCam.z);.Based on learnings: "NaN or Inf values have been observed in pan/zoom related fields due to unusual window sizes." Centralizing the ratio computation makes the guard easier to strengthen later (e.g. bailing out when
baseZ === HUNDRED_PERCENTfallback is returned).🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@bigbluebutton-html5/imports/ui/components/whiteboard/component.jsx` around lines 1470 - 1488, Extract a helper like updateStoredZoomRatio(nextCamZ) that (1) reads currentPresentationPageRef.current.scaledWidth/height, (2) calls calculateZoomValueRef.current(...) to get baseZ, (3) guards baseZ (baseZ > 0 and reject the HUNDRED_PERCENT sentinel if applicable), and (4) computes pKey = `${presentationIdRef.current}_${curPageIdRef.current}` and assigns pageActualZoomRatioRef.current[pKey] = nextCamZ / baseZ; replace the duplicated ratio-setting blocks in both the user-source listener and the api/presenter branch (the code using calculateZoomValueRef, pKey, and pageActualZoomRatioRef) with a call to updateStoredZoomRatio(nextCam.z); keep the existing updateCursorZoomRef.current?.() calls as they are.
2082-2082: RemovepresentationWidthandpresentationHeightfrom the effect dependencies.The
syncCameraWithPresentationArea()function only checks and usespresentationAreaWidthandpresentationAreaHeight— it never referencespresentationWidthorpresentationHeight. Since both pairs co-change on window resize (the former are derived from the latter), including the slide dimensions in the deps array causes this effect to fire twice per resize event. ThecancelAnimationFrameguards make this safe, but it's redundant work that can delay the final camera settle. Keep only the area dimensions in the deps.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@bigbluebutton-html5/imports/ui/components/whiteboard/component.jsx` at line 2082, Remove presentationWidth and presentationHeight from the effect dependency array that calls syncCameraWithPresentationArea(): the function only uses presentationAreaWidth and presentationAreaHeight, so update the deps to include presentationAreaWidth, presentationAreaHeight, curPageId, and presentationId (remove presentationWidth and presentationHeight) to avoid duplicate runs on resize; ensure you keep the existing cancelAnimationFrame guard and invocation of syncCameraWithPresentationArea() unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@bigbluebutton-html5/imports/ui/components/whiteboard/component.jsx`:
- Around line 1470-1488: Extract a helper like updateStoredZoomRatio(nextCamZ)
that (1) reads currentPresentationPageRef.current.scaledWidth/height, (2) calls
calculateZoomValueRef.current(...) to get baseZ, (3) guards baseZ (baseZ > 0 and
reject the HUNDRED_PERCENT sentinel if applicable), and (4) computes pKey =
`${presentationIdRef.current}_${curPageIdRef.current}` and assigns
pageActualZoomRatioRef.current[pKey] = nextCamZ / baseZ; replace the duplicated
ratio-setting blocks in both the user-source listener and the api/presenter
branch (the code using calculateZoomValueRef, pKey, and pageActualZoomRatioRef)
with a call to updateStoredZoomRatio(nextCam.z); keep the existing
updateCursorZoomRef.current?.() calls as they are.
- Line 2082: Remove presentationWidth and presentationHeight from the effect
dependency array that calls syncCameraWithPresentationArea(): the function only
uses presentationAreaWidth and presentationAreaHeight, so update the deps to
include presentationAreaWidth, presentationAreaHeight, curPageId, and
presentationId (remove presentationWidth and presentationHeight) to avoid
duplicate runs on resize; ensure you keep the existing cancelAnimationFrame
guard and invocation of syncCameraWithPresentationArea() unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 98a1d55f-0623-4277-821a-6c207d38f154
📒 Files selected for processing (1)
bigbluebutton-html5/imports/ui/components/whiteboard/component.jsx
There was a problem hiding this comment.
Pull request overview
Fixes presenter whiteboard “camera” drift on browser resize by refreshing zoom calculations and persisting the effective zoom ratio, and adds Playwright coverage to detect regressions (including visual checks).
Changes:
- Update whiteboard camera sync logic to use ref-backed zoom calculators (avoids stale closure values during resize) and to persist zoom ratio when camera updates come from API-driven changes.
- Simplify camera updates during resize by updating zoom based on stored ratios / toolbar zoom.
- Add new Playwright resize tests (ratio-based + visual regression) and commit new snapshot baselines.
Reviewed changes
Copilot reviewed 3 out of 11 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| bigbluebutton-html5/imports/ui/components/whiteboard/component.jsx | Adjusts zoom calculation plumbing and camera sync behavior during mount/resize; records zoom ratio from more camera update sources. |
| bigbluebutton-tests/playwright/whiteboard/whiteboardResize.ts | Adds automated resize/zoom regression tests (ratio assertions + screenshot comparisons). |
| bigbluebutton-tests/playwright/whiteboard/whiteboard.spec.ts | Wires the new resize tests into the existing whiteboard Playwright suite. |
| bigbluebutton-tests/playwright/whiteboard/whiteboard.spec.ts-snapshots/mod-whiteboard-resize-zoomed-shrunk-Chromium-linux.png | Adds a new snapshot baseline for the zoomed+shrunk scenario. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ramonlsouza
left a comment
There was a problem hiding this comment.
While testing, I found another way to reproduce the issue (and it happens even with the changes made in this pull request:
- increase zoom
- minimize presentation
- restore presentation
Screencast.from.2026-04-27.09-44-05.mp4
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
bigbluebutton-html5/imports/ui/components/whiteboard/component.jsx (2)
2253-2265:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winRemove the orphan
pageActualZoomRatioMapcleanup on line 2260.This
removeItemcall has no correspondingsetItemanywhere in the codebase. UnlikepageZoomMapandinitialViewBoxWidth/Height(which follow a complete read→write→cleanup pattern), the zoom ratio is persisted only in the module-level_pageZoomRatioCacheobject for cross-mount preservation, not in localStorage. TheremoveItemis dead code and should be removed.🤖 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-html5/imports/ui/components/whiteboard/component.jsx` around lines 2253 - 2265, The cleanup in the React.useEffect contains an orphan localStorage.removeItem('pageActualZoomRatioMap'); remove that single call from the effect's return cleanup so only the valid keys (initialViewBoxWidth, initialViewBoxHeight, pageZoomMap) are cleared; locate the useEffect in the whiteboard component (the block that sets setTldrawIsMounting(true) and references isMountedRef.current and mountedTimeoutIdRef.current) and delete the removeItem('pageActualZoomRatioMap') line.
1485-1503:⚠️ Potential issue | 🟠 Major | ⚡ Quick winTwo listeners now both populate
pageActualZoomRatioRef— but one path is missing.The user-source listener (line 1379) updates
pageActualZoomRatioRef.current[pageKey]when a presenter manually pans or zooms. This new api-source listener (lines 1485–1510) does the same forsource === 'api'changes fromsetCamera()calls (e.g.,syncCameraOnPresenterZoom).However,
syncCameraWithPresentationArea(line 1861) usesmergeRemoteChangesto push camera updates, which tldraw classifies assource: 'remote'—not'api'. Neither the user-source listener nor the new api-source listener will catch these updates, so the cached zoom ratio will silently lag behind actual presenter camera changes from resize/restore flows.Add
|| source === 'remote'to the condition at line 1489, or add a third listener for remote camera updates.🤖 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-html5/imports/ui/components/whiteboard/component.jsx` around lines 1485 - 1503, The listener registered via editor.store.listen that updates pageActualZoomRatioRef (using camKey, calculateZoomValueRef, currentPresentationPageRef, presentationIdRef, curPageIdRef and calling updateCursorZoomRef) only handles source === 'api'; update the condition to also treat source === 'remote' (i.e., change if (source === 'api' && isPresenterRef.current && isMountedRef.current) to include || source === 'remote') so syncCameraWithPresentationArea/mergeRemoteChanges updates are captured and the cached zoom ratio stays in sync.
🧹 Nitpick comments (4)
bigbluebutton-html5/imports/ui/components/whiteboard/component.jsx (1)
122-125: 💤 Low valueModule-level cache persists across all whiteboard remounts in the tab.
_pageZoomRatioCacheis a module-level singleton, so its entries accumulate for the entire lifetime of the tab/JS module. The unmount cleanup at line 2253-2265 only clears localStorage and never resets this object, so:
- Entries grow unbounded across slide/presentation/meeting changes (small in practice, but no upper bound).
- If two whiteboard component instances ever exist concurrently or if the module is reused after
setTldrawIsMounting(true), both share the same cache.Cache keys include
presentationIdRef.current, so cross-presentation contamination is unlikely, but consider clearing entries belonging to the unmounted presentation on cleanup (or pruning onpresentationIdchange) to keep the working set bounded.🤖 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-html5/imports/ui/components/whiteboard/component.jsx` around lines 122 - 125, _module-level _pageZoomRatioCache currently accumulates entries for the lifetime of the tab because cleanup only clears localStorage; modify the Whiteboard component's unmount/cleanup (the same place that calls setTldrawIsMounting(true) and clears localStorage) to also remove keys from _pageZoomRatioCache that belong to the unmounted presentation (use presentationIdRef.current or the presentationId prop to identify entries), or alternatively prune entries when presentationId changes in the componentDidUpdate / useEffect handler dealing with presentationId — this bounds memory and prevents cross-presentation sharing while keeping the cache behavior intact.bigbluebutton-tests/playwright/whiteboard/whiteboardResize.ts (2)
203-241: ⚡ Quick winDeduplicate the React-fiber-walking zoom helper.
Both
cameraResyncZoomedVisualandcameraResyncAfterMinimizeRestorecontain a near-identical ~35 linepage.evaluateblock that walks the fiber tree to find the tldraw editor and applies a 2× viewport-centered zoom. Extract this into a private method (e.g.applyDirectFiberZoom(page, factor = 2)) so future changes to the fiber-walk strategy or zoom math only need to be made in one place.Also applies to: 303-336
🤖 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/whiteboardResize.ts` around lines 203 - 241, The duplicated React-fiber-walking + zooming page.evaluate block used in cameraResyncZoomedVisual and cameraResyncAfterMinimizeRestore should be extracted into a private helper (suggested name applyDirectFiberZoom(modPage.page, factor = 2)) that accepts the Playwright Page and zoom factor, performs the same fiber walk, computes newZ = cam.z * factor and applies the viewport-centered camera set (returning boolean success); replace both inlined blocks with a call to this helper and assert its boolean result. Ensure the new helper mirrors the existing logic (checks `#whiteboard-element`, finds '__reactFiber' key, walks fiber.memoizedState/hooks, verifies ms.current.setCamera) and forwards { immediate: true } when calling setCamera so behavior remains identical.
65-65: ⚡ Quick winLong fixed
waitForTimeoutcalls make these tests slow and timing-fragile.This file relies on roughly a dozen
waitForTimeout(5000)/waitForTimeout(3000)/waitForTimeout(2000)calls (≈ 50+ s of pure sleep per scenario) to wait for the camera-mount polling chain, the React re-render aftersetViewportSize, and the post-restore remount. Replace at least the longest waits with assertions tied to the state you actually need:
- After mount: poll
getCameraZoom(...) > 0andgetWrapperWidth(...) > 0.- After a viewport change: wait for
getWrapperWidthto equal the expected new value.- After minimize/restore:
await this.modPage.page.locator(e.whiteboard).waitFor({ state: 'visible' })plus a poll ongetCameraZoom.This would meaningfully cut runtime and reduce CI flakiness without changing what's being verified.
Also applies to: 109-109, 116-116, 196-196, 244-244, 269-269, 274-274, 294-294, 341-341, 358-358, 363-363, 392-392, 405-405, 414-414
🤖 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/whiteboardResize.ts` at line 65, Replace long fixed sleeps (e.g., await this.modPage.page.waitForTimeout(5000)) with deterministic waits tied to UI state: after initial mount poll until getCameraZoom(...) > 0 and getWrapperWidth(...) > 0; after viewport changes wait for getWrapperWidth(...) to equal the expected width following setViewportSize; after minimize/restore use await this.modPage.page.locator(e.whiteboard).waitFor({ state: 'visible' }) and then poll getCameraZoom(...) to be > 0; update all occurrences (including the listed waitForTimeout calls) to use these assertions/polls so tests are faster and less flaky.bigbluebutton-tests/playwright/whiteboard/whiteboard.spec.ts (1)
12-23: ⚡ Quick winThread
testInfointo theresize[method]()call.
runResizeTestalready takestestInfoand uses it forinitModPage/initUserPage, but does not forward it to the actual scenario. Passing it (await resize[method](testInfo)) — and accepting an optionaltestInfo: TestInfoparameter on the methods that write snapshots — letscameraResyncZoomedVisualresolve baselines viatestInfo.snapshotPath(...)instead of hardcoded-Chromium-linux.pngpaths, matching how Playwright's owntoHaveScreenshotresolves them across platforms.Proposed change
- await resize[method](); + await resize[method](testInfo);🤖 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/whiteboard.spec.ts` around lines 12 - 23, runResizeTest currently initializes WhiteboardResize with testInfo but does not pass testInfo into the scenario methods; update runResizeTest to call await resize[method](testInfo) and modify the WhiteboardResize methods (cameraResync, cameraResyncVisual, cameraResyncZoomedVisual, cameraResyncAfterMinimizeRestore) to accept an optional testInfo?: TestInfo parameter and use testInfo.snapshotPath(...) when creating or resolving screenshot baselines instead of hardcoded "-Chromium-linux.png" names so cross-platform snapshot resolution works correctly.
🤖 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.
Outside diff comments:
In `@bigbluebutton-html5/imports/ui/components/whiteboard/component.jsx`:
- Around line 2253-2265: The cleanup in the React.useEffect contains an orphan
localStorage.removeItem('pageActualZoomRatioMap'); remove that single call from
the effect's return cleanup so only the valid keys (initialViewBoxWidth,
initialViewBoxHeight, pageZoomMap) are cleared; locate the useEffect in the
whiteboard component (the block that sets setTldrawIsMounting(true) and
references isMountedRef.current and mountedTimeoutIdRef.current) and delete the
removeItem('pageActualZoomRatioMap') line.
- Around line 1485-1503: The listener registered via editor.store.listen that
updates pageActualZoomRatioRef (using camKey, calculateZoomValueRef,
currentPresentationPageRef, presentationIdRef, curPageIdRef and calling
updateCursorZoomRef) only handles source === 'api'; update the condition to also
treat source === 'remote' (i.e., change if (source === 'api' &&
isPresenterRef.current && isMountedRef.current) to include || source ===
'remote') so syncCameraWithPresentationArea/mergeRemoteChanges updates are
captured and the cached zoom ratio stays in sync.
---
Nitpick comments:
In `@bigbluebutton-html5/imports/ui/components/whiteboard/component.jsx`:
- Around line 122-125: _module-level _pageZoomRatioCache currently accumulates
entries for the lifetime of the tab because cleanup only clears localStorage;
modify the Whiteboard component's unmount/cleanup (the same place that calls
setTldrawIsMounting(true) and clears localStorage) to also remove keys from
_pageZoomRatioCache that belong to the unmounted presentation (use
presentationIdRef.current or the presentationId prop to identify entries), or
alternatively prune entries when presentationId changes in the
componentDidUpdate / useEffect handler dealing with presentationId — this bounds
memory and prevents cross-presentation sharing while keeping the cache behavior
intact.
In `@bigbluebutton-tests/playwright/whiteboard/whiteboard.spec.ts`:
- Around line 12-23: runResizeTest currently initializes WhiteboardResize with
testInfo but does not pass testInfo into the scenario methods; update
runResizeTest to call await resize[method](testInfo) and modify the
WhiteboardResize methods (cameraResync, cameraResyncVisual,
cameraResyncZoomedVisual, cameraResyncAfterMinimizeRestore) to accept an
optional testInfo?: TestInfo parameter and use testInfo.snapshotPath(...) when
creating or resolving screenshot baselines instead of hardcoded
"-Chromium-linux.png" names so cross-platform snapshot resolution works
correctly.
In `@bigbluebutton-tests/playwright/whiteboard/whiteboardResize.ts`:
- Around line 203-241: The duplicated React-fiber-walking + zooming
page.evaluate block used in cameraResyncZoomedVisual and
cameraResyncAfterMinimizeRestore should be extracted into a private helper
(suggested name applyDirectFiberZoom(modPage.page, factor = 2)) that accepts the
Playwright Page and zoom factor, performs the same fiber walk, computes newZ =
cam.z * factor and applies the viewport-centered camera set (returning boolean
success); replace both inlined blocks with a call to this helper and assert its
boolean result. Ensure the new helper mirrors the existing logic (checks
`#whiteboard-element`, finds '__reactFiber' key, walks fiber.memoizedState/hooks,
verifies ms.current.setCamera) and forwards { immediate: true } when calling
setCamera so behavior remains identical.
- Line 65: Replace long fixed sleeps (e.g., await
this.modPage.page.waitForTimeout(5000)) with deterministic waits tied to UI
state: after initial mount poll until getCameraZoom(...) > 0 and
getWrapperWidth(...) > 0; after viewport changes wait for getWrapperWidth(...)
to equal the expected width following setViewportSize; after minimize/restore
use await this.modPage.page.locator(e.whiteboard).waitFor({ state: 'visible' })
and then poll getCameraZoom(...) to be > 0; update all occurrences (including
the listed waitForTimeout calls) to use these assertions/polls so tests are
faster and less flaky.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 0f30680a-bee6-4f5f-9aad-827ff61e5bd9
⛔ Files ignored due to path filters (2)
bigbluebutton-tests/playwright/whiteboard/whiteboard.spec.ts-snapshots/mod-whiteboard-resize-zoomed-initial-Chromium-linux.pngis excluded by!**/*.pngbigbluebutton-tests/playwright/whiteboard/whiteboard.spec.ts-snapshots/user-whiteboard-resize-zoomed-initial-Chromium-linux.pngis excluded by!**/*.png
📒 Files selected for processing (3)
bigbluebutton-html5/imports/ui/components/whiteboard/component.jsxbigbluebutton-tests/playwright/whiteboard/whiteboard.spec.tsbigbluebutton-tests/playwright/whiteboard/whiteboardResize.ts
ramonlsouza
left a comment
There was a problem hiding this comment.
zoom is now working as expected after minimizing+restoring, but zoom % in toolbar is still resetting to 100%
Screencast.from.2026-05-07.10-26-16.mp4
|
There was a problem hiding this comment.
♻️ Duplicate comments (1)
bigbluebutton-tests/playwright/whiteboard/whiteboardResize.ts (1)
264-291:⚠️ Potential issue | 🟠 Major | ⚡ Quick winHardcoded
-Chromium-linux.pngsuffix still diverges fromtoHaveScreenshot's platform-aware path.The baselines written at Lines 267-268 hardcode
-Chromium-linux.png, but the comparison at Lines 290-291 usestoHaveScreenshot('mod-whiteboard-resize-zoomed-initial.png', …)whose resolved path is built by Playwright from the current platform/project. On Linux/Chromium the two paths happen to align; on macOS/Windows the write goes to a stale path andtoHaveScreenshotcreates and reads a different baseline, defeating the “same-run baseline” design noted in the comment at Lines 258-263.Thread
testInfofrom the spec'srunResizeTesthelper into this method and resolve the path viatestInfo.snapshotPath(name)so the written file is exactly the filetoHaveScreenshotwill read.🔧 Suggested fix
- async cameraResyncZoomedVisual() { + async cameraResyncZoomedVisual(testInfo: import('@playwright/test').TestInfo) { ... - const snapshotDir = path.join(__dirname, 'whiteboard.spec.ts-snapshots'); - fs.mkdirSync(snapshotDir, { recursive: true }); - - const modInitialPath = path.join(snapshotDir, 'mod-whiteboard-resize-zoomed-initial-Chromium-linux.png'); - const userInitialPath = path.join(snapshotDir, 'user-whiteboard-resize-zoomed-initial-Chromium-linux.png'); + const modInitialPath = testInfo.snapshotPath('mod-whiteboard-resize-zoomed-initial.png'); + const userInitialPath = testInfo.snapshotPath('user-whiteboard-resize-zoomed-initial.png'); + fs.mkdirSync(path.dirname(modInitialPath), { recursive: true }); + fs.mkdirSync(path.dirname(userInitialPath), { recursive: true }); fs.writeFileSync(modInitialPath, await this.modPage.page.screenshot()); fs.writeFileSync(userInitialPath, await this.userPage.page.screenshot());🤖 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/whiteboardResize.ts` around lines 264 - 291, The snapshot write uses hardcoded '-Chromium-linux.png' suffixes which won't match Playwright's platform-aware paths used by toHaveScreenshot; update the whiteboard resize test to accept and use the testInfo from the spec helper (thread testInfo from runResizeTest into this function) and replace the manual path construction for modInitialPath and userInitialPath with calls to testInfo.snapshotPath('mod-whiteboard-resize-zoomed-initial.png') and testInfo.snapshotPath('user-whiteboard-resize-zoomed-initial.png') respectively so the written baseline files are the exact files toHaveScreenshot will read (references: this.modPage.page, this.userPage.page, runResizeTest, testInfo.snapshotPath).
🤖 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.
Duplicate comments:
In `@bigbluebutton-tests/playwright/whiteboard/whiteboardResize.ts`:
- Around line 264-291: The snapshot write uses hardcoded '-Chromium-linux.png'
suffixes which won't match Playwright's platform-aware paths used by
toHaveScreenshot; update the whiteboard resize test to accept and use the
testInfo from the spec helper (thread testInfo from runResizeTest into this
function) and replace the manual path construction for modInitialPath and
userInitialPath with calls to
testInfo.snapshotPath('mod-whiteboard-resize-zoomed-initial.png') and
testInfo.snapshotPath('user-whiteboard-resize-zoomed-initial.png') respectively
so the written baseline files are the exact files toHaveScreenshot will read
(references: this.modPage.page, this.userPage.page, runResizeTest,
testInfo.snapshotPath).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 8a21b52f-f872-4c33-9b6c-5ff9268dd85b
📒 Files selected for processing (2)
bigbluebutton-html5/imports/ui/components/whiteboard/component.jsxbigbluebutton-tests/playwright/whiteboard/whiteboardResize.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- bigbluebutton-html5/imports/ui/components/whiteboard/component.jsx
✅ Automated tests have passed! |
2c6d156
into
bigbluebutton:v3.0.x-develop


What does this PR do?
This PR fixes two bugs where the whiteboard "camera" failed to adapt to browser window resizing. Key updates include:
Closes Issue(s)
Closes #24949
How to test
Open a presentation and manually zoom in using the mouse wheel.
Resize the browser window. (Shrink and expand)
Expected Result: The slide should maintain its specific zoom level and relative alignment without snapping back to the default view or shifting off-center.
More
Without zoom
resize-normal.webm
With Zoom
resize-zoom.webm