Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 2, 2025

This PR fixes two bugs identified in the codebase:

Bug 1: Non-functional window close method in DevRenderer

The DevRenderer::Close() method in livekit-plugins-browser had its core functionality commented out, making it effectively a no-op:

void DevRenderer::Close() {
  // glfwSetWindowShouldClose(window_, GLFW_TRUE);
}

This prevented the development window from being properly closed when the Close method was called. The fix uncomments the glfwSetWindowShouldClose call to restore proper window closing behavior.

Bug 2: Mutable default argument in log_exceptions decorator

The log_exceptions function in livekit-agents used a mutable default argument anti-pattern:

def log_exceptions(msg: str = "", logger: logging.Logger = logging.getLogger()) -> Callable[[F], F]:

This creates the logger at function definition time rather than call time, which can lead to unexpected behavior if logging configuration changes after the function is defined. The fix changes this to:

def log_exceptions(msg: str = "", logger: logging.Logger | None = None) -> Callable[[F], F]:
    if logger is None:
        logger = logging.getLogger()

This follows Python best practices by avoiding mutable default arguments and ensures a fresh logger is obtained each time the function is called with the default value.

Both fixes are minimal, surgical changes that restore proper functionality without affecting the existing API or breaking backward compatibility.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@theomonnom theomonnom closed this Sep 2, 2025
Copilot AI changed the title [WIP] fix a random bug Fix window close functionality and mutable default argument anti-pattern Sep 2, 2025
Copilot AI requested a review from theomonnom September 2, 2025 00:30
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