Skip to content

fix(whiteboard): prevent presenter/viewer viewed-region desync after fullscreen - #24735

Merged
prlanzarin merged 1 commit into
bigbluebutton:v4.0.x-releasefrom
germanocaumo:pres-zoom-fix
Mar 13, 2026
Merged

prlanzarin merged 1 commit into
bigbluebutton:v4.0.x-releasefrom
germanocaumo:pres-zoom-fix

Conversation

@germanocaumo

Copy link
Copy Markdown
Contributor

What does this PR do?

Currently some zoom updates can leak to server when presenter enter/leaves presentation to fullscreen (maybe other cases also). It causes viewers and recording to have zoom, while presenter still see full slide.

This commit prevent transient in-between camera/zoom values to be propagated, while still syncing the correct final state when needed (mainly fit-to-width).

Closes Issue(s)

Possbile fixes #24670

Motivation

Wrong zoom in recordings when the presenter hasn't changed the zoom during meeting.

How to test

The bug in question is very hard to reproduce, it's a race condition and I believe it happened more when the system is under load. But the easiest way was by putting the presentation fullscreen, sometimes the wrong zoom was applied only to viewers, not for the presenter

…fullscreen

Currently some zoom updates can leak to server when presenter enter/leaves presentation to fullscreen (maybe other cases also). It causes viewers and recording to have zoom, while presenter still see full slide.

This commit prevent transient in-between camera/zoom values to be propagated, while still syncing the correct final state when needed (mainly fit-to-width).
@coderabbitai

coderabbitai Bot commented Mar 11, 2026 •

Copy link
Copy Markdown
Contributor

Walkthrough

The whiteboard component is enhanced with improved presenter view synchronization logic. A new lastForcedViewRef state reference is introduced to track the final presenter view. When updating the presenter camera, the change uses mergeRemoteChanges to prevent triggering user-source listeners. A computed forcedView object (containing pageId, width, height, x, and y coordinates) is calculated and compared against the last forced view to avoid redundant updates. When fitToWidth is active, the component triggers zoomSlide to broadcast the final settled presenter view via a stepped, animation-driven zoom mechanism. This augments how remote camera updates are handled and ensures proper view synchronization for presenter-to-presenter camera interactions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main fix: preventing presenter/viewer zoom desync when fullscreen mode is toggled, which directly addresses the changeset's core objective.
Description check ✅ Passed The description explains the bug (transient zoom leaks to server during fullscreen), the solution (preventing propagation of intermediate states), and references the related issue.
Linked Issues check ✅ Passed The code changes implement the core fix to prevent transient zoom/camera updates from propagating, which directly addresses issue #24670's root cause of zoomed recordings.
Out of Scope Changes check ✅ Passed The changes are narrowly scoped to whiteboard component camera/zoom handling during presenter state transitions, staying within the bounds of the linked issue.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 and usage tips.

@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 the current code and only fix it if needed.

Inline comments:
In `@bigbluebutton-html5/imports/ui/components/whiteboard/component.jsx`:
- Line 216: The deferred publish can send stale camera coords because
lastForcedViewRef only stores page number and updatedCurrentCam is captured but
validated later; modify the logic around lastForcedViewRef and the deferred
zoomSlide enqueue to store a stable identity object that includes presentationId
(or presentation UID) and pageId (not just page number) along with the camera
coords, and when the debounced callback runs (the zoomSlide enqueue path)
compare the stored presentationId+pageId against the current
presentationId+pageId before publishing; only call zoomSlide/publish if they
match, otherwise drop the deferred action; update references to
forcedView.pageId to use the unique page identifier to avoid cross-presentation
dedupe collisions (search for lastForcedViewRef, forcedView.pageId, and
zoomSlide in the component and container to apply the check).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: f0130002-02ba-42f7-89e0-80eb452599b0

📥 Commits

Reviewing files that changed from the base of the PR and between cc45fec and 3b94bc9.

📒 Files selected for processing (1)
  • bigbluebutton-html5/imports/ui/components/whiteboard/component.jsx

const innerWrapperPollingFrameRef = React.useRef(null);
const isMountedPollingFrameRef = React.useRef(null);
const hasZoomSyncedRef = useRef(false);
const lastForcedViewRef = useRef(null);

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.

⚠️ Potential issue | 🟠 Major

Guard the deferred publish with stable page/presentation identity.

This callback captures updatedCurrentCam, but it reads the current page refs later. If the presenter changes slide or presentation before the next frame, it can enqueue zoomSlide with stale camera coordinates for the wrong page. Given that zoomSlide is debounced in bigbluebutton-html5/imports/ui/components/whiteboard/container.jsx:199-217, that stale publish can also win the 500ms window. Also, forcedView.pageId is using the page number, so the dedupe can collide across presentations.

Suggested fix
       if (fitToWidthRef.current) {
-        requestAnimationFrame(() => {
+        const expectedPresentationId = presentationIdRef.current;
+        const expectedPage = {
+          pageId: currentPresentationPageRef.current?.pageId,
+          num: currentPresentationPageRef.current?.num,
+        };
+        const forcedX = updatedCurrentCam.x;
+        const forcedY = updatedCurrentCam.y;
+
+        requestAnimationFrame(() => {
+          if (
+            !fitToWidthRef.current
+            || presentationIdRef.current !== expectedPresentationId
+            || currentPresentationPageRef.current?.pageId !== expectedPage.pageId
+          ) {
+            return;
+          }
+
           const viewportPageBounds = tlEditorRef.current?.getViewportPageBounds();
           if (!viewportPageBounds?.w || !viewportPageBounds?.h) {
             return;
           }
@@
           const forcedView = {
-            pageId: curPageIdRef.current,
+            presentationId: expectedPresentationId,
+            pageId: expectedPage.pageId,
             w: Number(viewedRegionW.toFixed(6)),
             h: Number(viewedRegionH.toFixed(6)),
-            x: Number(updatedCurrentCam.x.toFixed(6)),
-            y: Number(updatedCurrentCam.y.toFixed(6)),
+            x: Number(forcedX.toFixed(6)),
+            y: Number(forcedY.toFixed(6)),
           };
@@
           zoomSlide(
             viewedRegionW,
             viewedRegionH,
-            updatedCurrentCam.x,
-            updatedCurrentCam.y,
-            currentPresentationPageRef.current,
+            forcedX,
+            forcedY,
+            expectedPage,
           );
         });
       }

Also applies to: 1747-1783

🤖 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
216, The deferred publish can send stale camera coords because lastForcedViewRef
only stores page number and updatedCurrentCam is captured but validated later;
modify the logic around lastForcedViewRef and the deferred zoomSlide enqueue to
store a stable identity object that includes presentationId (or presentation
UID) and pageId (not just page number) along with the camera coords, and when
the debounced callback runs (the zoomSlide enqueue path) compare the stored
presentationId+pageId against the current presentationId+pageId before
publishing; only call zoomSlide/publish if they match, otherwise drop the
deferred action; update references to forcedView.pageId to use the unique page
identifier to avoid cross-presentation dedupe collisions (search for
lastForcedViewRef, forcedView.pageId, and zoomSlide in the component and
container to apply the check).

@github-actions

Copy link
Copy Markdown

🚨 Automated tests failed

@prlanzarin prlanzarin added this to the Release 4.0 milestone Mar 13, 2026
@prlanzarin

prlanzarin commented Mar 13, 2026 •

Copy link
Copy Markdown
Member

Tested locally, with induced load on client and server as well - works ok, although, as mentioned in the description, the original issue is hard to reproduce so we'll have to observe with some actual usage.

This likely could be backported into 3.0 cc @antobinary @germanocaumo ?

@prlanzarin
prlanzarin self-requested a review March 13, 2026 13:08
@prlanzarin
prlanzarin merged commit ed5e0bf into bigbluebutton:v4.0.x-release Mar 13, 2026
29 of 30 checks passed
@antobinary

Copy link
Copy Markdown
Member

Please backport to 3.0 as we're receiving a bunch of reports of issues that this might resolve 🤞
@germanocaumo or @ramonlsouza perhaps?

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.

3 participants