Skip to content

fix(learning-dashboard): prevent actor crashes on missing activity state - #25272

Merged
lfzawacki merged 3 commits into
bigbluebutton:v4.0.x-developfrom
germanocaumo:fix-learning-dashboard
Jun 23, 2026
Merged

lfzawacki merged 3 commits into
bigbluebutton:v4.0.x-developfrom
germanocaumo:fix-learning-dashboard

Conversation

@germanocaumo

@germanocaumo germanocaumo commented Jun 16, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Prevents LearningDashboardActor from crashing when dashboard events arrive without the expected in-memory activity/session state.

Learning dashboard changes include:

  • Guard learning dashboard event handling with NonFatal logging.
  • Guard dashboard report sending so one failed report does not stop future updates.
  • Replace unsafe .last, .init, and last-item vector updates with lastOption-based handling.
  • Add small helpers for user session state checks and transitions.
  • Safely no-op when presentation, away, webcam, screenshare, or user-session state is missing/already closed.
  • Refactor the touched code to use clearer names and intermediate values.

Follow-up commits also:

  • Show the lock settings action inside breakout rooms and adapt the new breakout lock-settings Playwright tests to the v4 interface.
  • Update whiteboard snapshots to make CI tests pass.

Motivation

During a live meeting, learning dashboard data stopped updating because LearningDashboardActor crashed on an event with missing activity state.

The crash happened when the actor tried to close a webcam entry using .last on an empty webcam vector. Since the actor keeps active meeting dashboard data in memory, the actor restart lost the current state and left the dashboard data stale.

The follow-up commits keep the v4 test environment aligned with the current interface.

More

The normal successful learning-dashboard event flow is preserved. The intentional behavior change is that missing or already-closed activity state now no-ops safely instead of throwing an exception and restarting the actor.

@coderabbitai

coderabbitai Bot commented Jun 16, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

The PR makes three independent sets of changes. First, LearningDashboardActor adds a NonFatal import and exception-handling wrappers (handleBbbCommonEnvCoreMsgSafely, sendReportSafely) to prevent actors from crashing on message/report failures. Presentation slide mutations shift to lastOption-based matching with shouldAppendSlide guards and fallback logic for slide derivation. Seven new session helpers (replaceLastItem, hasOpenSession, hasOpenFlaggedSession, closeOpenSession, reopenSession, closeUserIdForMeetingEnd) are introduced and applied across user-join, user-left, voice-conf-left, away-status, camera-stop, and screenshare-stop handlers. addUserToMeeting is rewritten to select existing-or-new users, close stale sessions, and append fresh UserSession entries. Meeting shutdown applies userWithLeftProps with per-intId session closing before calling sendReportSafely.

Second, the CrowdActionButtons component removes its isBreakout prop dependency, allowing the lock settings button to render unconditionally. The types and parent component render calls are updated accordingly.

Third, breakout Playwright tests consolidate duplicated setup/verification patterns into eight new private helpers (audio modal closure, permission checking, lock viewers navigation, inherited breakout creation, join-as-moderator). Eight existing lock-settings test cases are rewritten to call these helpers, reducing duplication. A new roomOptions1 selector is added for breakout room option buttons, and the options keyboard navigation test is corrected to assert focus on a fullscreen menu item instead of the presence toggle.

🎯 4 (Complex) | ⏱️ ~60 minutes

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Suggested reviewers

  • ramonlsouza
  • Arthurk12
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the primary change: preventing LearningDashboardActor crashes when activity state is missing, which is the core motivation and main objective of this PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The pull request description clearly explains the changes made to prevent LearningDashboardActor from crashing and the follow-up improvements to the breakout room UI and tests.

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

✨ 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.

@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
`@akka-bbb-apps/src/main/scala/org/bigbluebutton/endpoint/redis/LearningDashboardActor.scala`:
- Around line 1063-1094: The code closes matching open sessions in the
`usersWithClosedPreviousSessions` mapping (lines 1068-1077), but when creating
`updatedUser` from the original `user` at lines 1079-1088, it rebuilds the
intIds without applying the same closure logic to `currentUserId`. When
`currentUserId` already has an open session, line 1087-1088 appends a new
UserSession without first closing the existing open one. Fix this by closing any
open session in `currentUserId` before appending the new UserSession, using the
same pattern as the `closeOpenSession` call within the
`usersWithClosedPreviousSessions` mapping.
🪄 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: e357131d-b5fa-449e-9395-37567a46191d

📥 Commits

Reviewing files that changed from the base of the PR and between 7361050 and f12a45b.

📒 Files selected for processing (1)
  • akka-bbb-apps/src/main/scala/org/bigbluebutton/endpoint/redis/LearningDashboardActor.scala

@antobinary antobinary added this to the Release 4.0 milestone Jun 16, 2026
@ramonlsouza
ramonlsouza requested a review from GuiLeme June 18, 2026 16:29
@germanocaumo
germanocaumo force-pushed the fix-learning-dashboard branch from a0d754f to 10765a9 Compare June 19, 2026 16:20
@github-actions

Copy link
Copy Markdown

This pull request has conflicts ☹
Please resolve those so we can review the pull request.
Thanks.

The learning dashboard actor could crash when stop/leave/end events arrived
without the corresponding in-memory activity item. For example, a webcam stop
event could call `.last` on an empty webcam vector, throwing
NoSuchElementException and restarting the actor. Since the actor keeps meeting
dashboard data in memory, that restart caused active meetings to stop receiving
dashboard updates.

Guard learning dashboard message handling and report sending with NonFatal
logging so one bad event or report failure does not restart the actor. Replace
unsafe `.last`, `.init`, and `dropRight(1)` updates with `lastOption`-based
handling and small helper methods for user session state transitions.

Also refactor the touched logic for readability:
- add helpers for open/flagged sessions and closing/reopening sessions
- use explicit matches for presentation, away, webcam, and screenshare state
- split user rejoin handling into named intermediate values
- use `meetings.values.foreach(sendReportSafely)` for periodic reports

Normal event behavior is preserved; the intentional behavior change is that
missing or already-closed activity state now no-ops safely and logs failures
instead of crashing the actor.
Fix lock settings options was not showing inside breakouts for moderator.
Fix and refactor lock settings tests in breakouts, create shared helpers that are used in multipe tests.
Update some screenshots.

@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/breakout/create.ts`:
- Around line 8-15: The catch block in closeAudioModalIfPresent is too broad and
catches all errors, including legitimate failures like a failed click on the
close button. Narrow the exception handling to only wrap the first
page.locator(e.audioModal).waitFor call that checks for the visible state, which
is the operation expected to fail when the audio modal is not present. Move the
click operation on e.closeModal and the subsequent waitFor call for the detached
state outside and after the try-catch block, or into a separate try block, so
that actual failures in those operations propagate and are not silently masked
as expected behavior.
🪄 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: b1d24cd1-bb6b-4e85-b233-8fce67dc54ed

📥 Commits

Reviewing files that changed from the base of the PR and between c6472f9 and 5f01c28.

⛔ Files ignored due to path filters (8)
  • bigbluebutton-tests/playwright/webcam/webcam.spec.ts-snapshots/drag-drop-areas-Chromium-linux.png is excluded by !**/*.png
  • bigbluebutton-tests/playwright/webcam/webcam.spec.ts-snapshots/drag-drop-bottom-Chromium-linux.png is excluded by !**/*.png
  • bigbluebutton-tests/playwright/webcam/webcam.spec.ts-snapshots/drag-drop-left-Chromium-linux.png is excluded by !**/*.png
  • bigbluebutton-tests/playwright/webcam/webcam.spec.ts-snapshots/drag-drop-right-Chromium-linux.png is excluded by !**/*.png
  • bigbluebutton-tests/playwright/webcam/webcam.spec.ts-snapshots/drag-drop-sidebar-bottom-Chromium-linux.png is excluded by !**/*.png
  • bigbluebutton-tests/playwright/webcam/webcam.spec.ts-snapshots/drag-drop-top-Chromium-linux.png is excluded by !**/*.png
  • bigbluebutton-tests/playwright/whiteboard/whiteboard.spec.ts-snapshots/mod-whiteboard-resize-initial-Chromium-linux.png is excluded by !**/*.png
  • bigbluebutton-tests/playwright/whiteboard/whiteboard.spec.ts-snapshots/mod-whiteboard-resize-shrunk-Chromium-linux.png is excluded by !**/*.png
📒 Files selected for processing (6)
  • bigbluebutton-html5/imports/ui/components/user-list/component.tsx
  • bigbluebutton-html5/imports/ui/components/user-list/crowd-action-buttons/component.tsx
  • bigbluebutton-html5/imports/ui/components/user-list/crowd-action-buttons/types.ts
  • bigbluebutton-tests/playwright/breakout/create.ts
  • bigbluebutton-tests/playwright/core/elements.ts
  • bigbluebutton-tests/playwright/options/options.ts
💤 Files with no reviewable changes (1)
  • bigbluebutton-html5/imports/ui/components/user-list/crowd-action-buttons/types.ts
✅ Files skipped from review due to trivial changes (1)
  • bigbluebutton-tests/playwright/core/elements.ts

Comment on lines +8 to +15
private static async closeAudioModalIfPresent(page: PlaywrightPage) {
try {
await page.locator(e.audioModal).waitFor({ state: 'visible', timeout: ELEMENT_WAIT_TIME });
await page.locator(e.closeModal).click();
await page.locator(e.audioModal).waitFor({ state: 'detached', timeout: ELEMENT_WAIT_LONGER_TIME });
} catch {
/* audio modal not present */
}

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 | 🟡 Minor | ⚡ Quick win

Narrow the exception handling in closeAudioModalIfPresent.

At Line [13], catching all errors can mask real failures after the audio modal becomes visible (for example, failing to click close), which can produce false-positive test outcomes.

Proposed fix
 private static async closeAudioModalIfPresent(page: PlaywrightPage) {
-  try {
-    await page.locator(e.audioModal).waitFor({ state: 'visible', timeout: ELEMENT_WAIT_TIME });
-    await page.locator(e.closeModal).click();
-    await page.locator(e.audioModal).waitFor({ state: 'detached', timeout: ELEMENT_WAIT_LONGER_TIME });
-  } catch {
-    /* audio modal not present */
-  }
+  const audioModal = page.locator(e.audioModal);
+  const isAudioModalVisible = await audioModal
+    .isVisible({ timeout: ELEMENT_WAIT_TIME })
+    .catch(() => false);
+
+  if (!isAudioModalVisible) return;
+
+  await page.locator(e.closeModal).click();
+  await audioModal.waitFor({ state: 'detached', timeout: ELEMENT_WAIT_LONGER_TIME });
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
private static async closeAudioModalIfPresent(page: PlaywrightPage) {
try {
await page.locator(e.audioModal).waitFor({ state: 'visible', timeout: ELEMENT_WAIT_TIME });
await page.locator(e.closeModal).click();
await page.locator(e.audioModal).waitFor({ state: 'detached', timeout: ELEMENT_WAIT_LONGER_TIME });
} catch {
/* audio modal not present */
}
private static async closeAudioModalIfPresent(page: PlaywrightPage) {
const audioModal = page.locator(e.audioModal);
const isAudioModalVisible = await audioModal
.isVisible({ timeout: ELEMENT_WAIT_TIME })
.catch(() => false);
if (!isAudioModalVisible) return;
await page.locator(e.closeModal).click();
await audioModal.waitFor({ state: 'detached', timeout: ELEMENT_WAIT_LONGER_TIME });
}
🤖 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/breakout/create.ts` around lines 8 - 15, The
catch block in closeAudioModalIfPresent is too broad and catches all errors,
including legitimate failures like a failed click on the close button. Narrow
the exception handling to only wrap the first page.locator(e.audioModal).waitFor
call that checks for the visible state, which is the operation expected to fail
when the audio modal is not present. Move the click operation on e.closeModal
and the subsequent waitFor call for the detached state outside and after the
try-catch block, or into a separate try block, so that actual failures in those
operations propagate and are not silently masked as expected behavior.

@germanocaumo
germanocaumo force-pushed the fix-learning-dashboard branch from 478c405 to 7989980 Compare June 23, 2026 14:16
@github-actions

Copy link
Copy Markdown

🚨 Automated tests failed

@lfzawacki
lfzawacki merged commit 7ba2ac8 into bigbluebutton:v4.0.x-develop Jun 23, 2026
59 of 69 checks passed
@sonarqubecloud

Copy link
Copy Markdown

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