Skip to content

Conversation

@deepak0x
Copy link
Contributor

@deepak0x deepak0x commented Jan 20, 2026

This pull request fixes a severe performance issue where the AudioMessageRecorder and VideoMessageRecorder components were entering an infinite render loop, leading to high CPU usage and unstable UI behavior.


Root Cause

The handleMount function in both components was defined using useCallback without a dependency array.

In React:

  • A useCallback without dependencies returns a new function reference on every render.
  • Both components used handleMount as a dependency of a useEffect that invokes it.

This caused the following loop:

  1. Component renders
  2. New handleMount function reference is created
  3. useEffect detects a dependency change and runs
  4. handleMount executes
  5. Internal state updates and permission/device queries trigger a re-render
  6. The cycle repeats indefinitely

This issue was especially noticeable when typing in the ChatInput or during UI state updates.


Closes #1083

Video/Screenshots

PR Test Details

Note: The PR will be ready for live testing at https://rocketchat.github.io/EmbeddedChat/pulls/pr-<pr_number> after approval. Contributors are requested to replace <pr_number> with the actual PR number.

@deepak0x deepak0x force-pushed the fix/infinite-render-loop-media-recorders branch from 35379c9 to a1b8395 Compare January 20, 2026 16:46
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.

Bug: Performance Degradation: Infinite Render Loop in Media Recorders

1 participant