useAudio/useVideo play lock resets across renders
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 75/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 静か
- 技術スタック
- react, typescript
調査の方向性
createHTMLMediaHook と issue に記載されている lockPlay の処理から始め、続いてメディアイベントの再レンダリング経路を追跡します。play() が完了するまでロックが再レンダリング後も維持され、保留中の play に対する pause のケースを対象とした集中的なリグレッションテストが含まれていれば完了です。
索引モデルが issue の本文から書いたものです。
説明
What is the current behavior?
useAudio and useVideo use a lockPlay local variable inside createHTMLMediaHook to avoid calling pause() while a pending HTMLMediaElement.play() promise is still resolving.
Because lockPlay is a plain local variable, it is recreated on every render. Media events such as play, playing, waiting, pause, durationchange, or timeupdate can call setState, causing a rerender before the original play() promise settles. After that rerender, the lock is reset to false, so a new controls.pause() call can run while the earlier play() promise is still pending.
This weakens the Chromium workaround described in the comment above the lock:
Some browsers return
Promiseon.play()and may throw errors if one tries to execute another.play()or.pause()while that promise is resolving.
Expected behavior
The play lock should persist across renders until the pending play() promise resolves or rejects.
Using a ref for the lock would preserve the intended behavior without changing the public API.
Why this matters
In video/audio-heavy UIs, components often call controls.play() and controls.pause() in response to store changes, user interactions, or source changes. If a media event causes a rerender while play() is still pending, the current lock can be lost and the hook can issue a conflicting pause().
Possible fix
Change the local variable:
let lockPlay = false;
to a ref-backed value, for example:
const lockPlay = useRef(false);
and read/write lockPlay.current inside the controls.
I can open a PR with a focused regression test if this direction sounds good.
- 主要言語
- TypeScript
- スター
- 44k
- フォーク
- 3.3k
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
streamich/react-use のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
Add Generic Fn for useDebounce対応中かも @itsmejay80 が 189 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
-
useVideo.story.tsx - sampleVideo can not be loaded再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 62/100
-
useSlider: event callbacks are not updated対応中かも @erykpiast が 1836 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
streamich/react-use の issue をすべて見る
似ている issue
-
backend priority:P3 privacy-fix
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
bug desktop v3 windows
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
esengine/DeepSeek-Reasonix#13697 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
area:security documentation effort:S priority:P2
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
メンテナーはふだん 1 日以内に返信
-
app:web meta:ops
難易度 2/5 半日 初心者へのやさしさ 78/100
osu-tournament-rating/otr#1113 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100