Skip to content

Conversation

@GuoLei1990
Copy link
Member

@GuoLei1990 GuoLei1990 commented Dec 29, 2025

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

What is the current behavior? (You can also link to an open issue here)

What is the new behavior (if this is a feature change)?

Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)

Other information:

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced audio playback stability with improved handling of cancellation scenarios during resume operations, preventing potential playback errors when requests are interrupted.

✏️ Tip: You can customize this high-level summary in your review settings.

@GuoLei1990 GuoLei1990 added bug Something isn't working Audio labels Dec 29, 2025
@coderabbitai
Copy link

coderabbitai bot commented Dec 29, 2025

Walkthrough

Modified the play() method in AudioSource.ts to consolidate initial guard conditions and add cancellation detection during the async AudioManager.resume() path. The changes exit early if no audio source exists, playback is already active, or if a pending play is cancelled mid-resume.

Changes

Cohort / File(s) Summary
Audio playback guard consolidation
packages/core/src/audio/AudioSource.ts
Unified initial guard conditions in play() method into single conditional. Added early-exit guard in async resume path to detect and handle cancellation of pendingPlay flag before continuing with playback validation and start logic.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🎧✨ A guard stands watch where async calls dance,
Catching cancellations mid-resume trance,
The pending flag whispers its silent refrain,
While playback flows smooth without race-condition pain! 🐰

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Fix audio play when stop and pause' is partially related to the changeset. It mentions audio play and pause/stop operations, which align with the AudioSource.ts changes, but the phrasing is unclear and grammatically awkward, making it difficult to understand the specific issue being addressed. Consider rephrasing to be more specific and grammatically clear, such as 'Fix audio playback when resumed after stop/pause' or 'Prevent audio playback race conditions during pause/resume operations'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 39dcd8a and b2ae330.

📒 Files selected for processing (1)
  • packages/core/src/audio/AudioSource.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: e2e (22.x, 4/4)
  • GitHub Check: e2e (22.x, 1/4)
  • GitHub Check: codecov
🔇 Additional comments (2)
packages/core/src/audio/AudioSource.ts (2)

155-157: Good consolidation of guard conditions.

Adding this._pendingPlay to the guard prevents re-entry into play() while an async resume is in progress, correctly avoiding duplicate play requests.


167-170: Correct cancellation detection for stop/pause during async resume.

This check properly handles the race condition where stop() or pause() could be called while AudioManager.resume() is pending. Since both methods set _pendingPlay = false (lines 190 and 205), this guard correctly prevents playback from starting after cancellation.


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.

@codecov
Copy link

codecov bot commented Dec 29, 2025

Codecov Report

❌ Patch coverage is 20.00000% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.21%. Comparing base (39dcd8a) to head (b2ae330).

Files with missing lines Patch % Lines
packages/core/src/audio/AudioSource.ts 20.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2875      +/-   ##
==========================================
+ Coverage   78.03%   78.21%   +0.17%     
==========================================
  Files         867      867              
  Lines       94347    94348       +1     
  Branches     9401     9397       -4     
==========================================
+ Hits        73626    73794     +168     
+ Misses      20560    20393     -167     
  Partials      161      161              
Flag Coverage Δ
unittests 78.21% <20.00%> (+0.17%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Audio bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant