Repository navigation
fix(whiteboard): prevent presenter/viewer viewed-region desync after fullscreen - #24735
Conversation
…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).
WalkthroughThe whiteboard component is enhanced with improved presenter view synchronization logic. A new Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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: 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
📒 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); |
There was a problem hiding this comment.
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).
🚨 Automated tests failed |
|
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 ? |
ed5e0bf
into
bigbluebutton:v4.0.x-release
|
Please backport to 3.0 as we're receiving a bunch of reports of issues that this might resolve 🤞 |



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