Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Channel negotiation drops buffer swaps when several graph changes land in one render quantum

オープン
#1,332 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@mdydek がすでに取り組んでいます。

2026年10月14日 から。

  • #1343 @mdydek による — オープン

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
cpp, react-native

調査の方向性

Start in common/cpp/audioapi/core/utils/graph/HostGraph.cpp, especially buildNegotiatedBufferIfNeeded, then inspect HostGraph::Node and initialization in addNode. Add the described reproductions to common/cpp/test/src/graph/GraphTest.cpp and run the graph tests; done means the batched channel changes leave the destination at the expected channel count.

索引モデルが issue の本文から書いたものです。

説明

bug
Description

While a context is rendering, HostGraph can leave a node with the wrong channel count. Stereo
content then plays mono, and a StereoPannerNode or PannerNode placed after it no longer pans.
On a device it is intermittent: it depends on whether an audio callback runs between the JS calls.

buildNegotiatedBufferIfNeeded (common/cpp/audioapi/core/utils/graph/HostGraph.cpp) runs on the
JS thread. It skips the swap when the node's live buffer already has the computed channel count.
Swaps queued earlier in the same batch have not reached the audio thread yet. So when a node goes
2 → 1 → 2 within one batch, the second negotiation sees the live 2 and queues nothing, and the
queued swap to 1 is applied last. Offline before startRendering(), or in a suspended context, the
producer drains its own events, so the live buffer is current and the bug does not show.

A common JS pattern that should hit it (inferred from reading the code; the C++ test below is the
verified reproduction):

// In one JS task, while the context is running:
const source = ctx.createBufferSource();
source.connect(gain);         // no buffer yet: 1 output channel, gain -> 1 is queued
source.buffer = stereoBuffer; // 2 output channels: gain's live buffer still has 2, nothing is queued
source.start();               // gain stays mono

Another one: a mono source and a StereoPannerNode connected to the same gain in one task. This is
what Howler's sound.stereo(pan) does: the gain stays mono and the panned output collapses to the
center.

Steps to reproduce

Add this to common/cpp/test/src/graph/GraphTest.cpp. There is no processEvents() between the two
changes, as on a running context where both apply in the same render quantum:

TEST_F(GraphTest, ComputedNumberOfChannels_MaxMode_BatchedChangesBackToLiveWidth) {
  auto *mono = addChannelCountNode(*graph, {.channelCount = 1, .mode = ChannelCountMode::EXPLICIT});
  auto *stereo = addChannelCountNode(*graph, {.channelCount = 2, .mode = ChannelCountMode::EXPLICIT});
  auto *dest = addChannelCountNode(*graph, {.channelCount = 2, .mode = ChannelCountMode::MAX});
  graph->processEvents();

  ASSERT_TRUE(graph->addEdge(mono, dest).is_ok());
  ASSERT_TRUE(graph->addEdge(stereo, dest).is_ok());
  graph->processEvents();

  EXPECT_EQ(channelsOf(dest), 2u); // fails on main: 1
}

The same happens with addEdge(mono, dest) followed by removeEdge(mono, dest) (expected 2, got
1), and with a source whose output channel number changes from 1 to 2 after addEdge, followed by
renegotiateNodeChannels (expected 2, got 1). All three fail on main (b8491e1).

Proposed fix

Record on HostGraph::Node the channel count of the last swap queued for the audio thread,
initialized in addNode (AudioGraph does not know the node yet, so reading its buffer there is
safe), and compare against it instead of the live buffer. With this change the three cases pass, and
so do the smoke suite (460 tests) and the graph category (659 tests). I can open a PR with the fix
and the tests.

Snack or a link to a repository

no React Native app. We embed the C++ engine in a custom iOS runtime; the reproduction is the GraphTest case above.

React Native Audio API version

1.0.0

React Native version

0.75.3

Platforms

iOS

JavaScript runtime

Hermes

Workflow

None

Architecture

None

Build type

None

Device

Real device

Device model

No response

Acknowledgements

Yes

主要言語
C++
スター
848
フォーク
95
平均マージ
3日 19時間
マージ済み PR(30日)
30

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

software-mansion/react-native-audio-api のほかの issue

software-mansion/react-native-audio-api の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。