Description
I'm getting an issue where the onPositionChanged callback is being called erroneously. It happens after I've already removed it and disconnected the source it was attached to, and I try to decode new audio data. YOu can't run my code exactly because it uses a lot of unrelated stuff. I put some effort into breaking it down into a snack, but I can't run it because I can't seem to install react-native-audio-api in the snack env. But you can read my code and see my logs, and confirm that the onPositionChanged callback fired at the wrong time, as far as I understand.
Steps to reproduce
- Create audio context
- use context to decodeAudioData on a local file uri
- create gain node and attach to destination
- createBufferSource, and set buffer to the result of decodeAudioData
- connect buffer source to gain node
- add onPositionChanged callback to buffer source:
audioBufferSource.onPositionChanged = (e) => {
console.log("onPositionChanged", this.pos, e.value);
this.pos = e.value;
};
- start buffer source, and playback works and onPositionChanged is called as expected
- after some time, remove onPositionChanged with:
audioBufferSource.onPositionChanged = null;
- then call source.stop() and source.disconnect()
- now, I try to play different audio with the same context, starting with decodeAudioData on a new local file uri
At this point, the onPositionChanged callback from the old source that has been stopped and disconnected fires some of the time. I'm not sure if the new call to decodeAudioData actually triggers it, or if it just happens to line up timing wise. I will post my code and my a picture of the resulting logs. In my code, each song actually has a few tracks, each with their own audioBufferSource, but only the first one has the onPositionChanged callback.
Player.js
Snack or a link to a repository
https://snack.expo.dev/@gearle/late-audiopositionchanged-cb
React Native Audio API version
0.12.2
React Native version
0.85.3
Platforms
iOS
JavaScript runtime
None
Workflow
Expo Dev Client
Architecture
Fabric (New Architecture)
Build type
Debug app & dev bundle
Device
iOS simulator
Device model
iPhone 15 Simulator
Acknowledgements
Yes
Description
I'm getting an issue where the onPositionChanged callback is being called erroneously. It happens after I've already removed it and disconnected the source it was attached to, and I try to decode new audio data. YOu can't run my code exactly because it uses a lot of unrelated stuff. I put some effort into breaking it down into a snack, but I can't run it because I can't seem to install react-native-audio-api in the snack env. But you can read my code and see my logs, and confirm that the onPositionChanged callback fired at the wrong time, as far as I understand.
Steps to reproduce
At this point, the onPositionChanged callback from the old source that has been stopped and disconnected fires some of the time. I'm not sure if the new call to decodeAudioData actually triggers it, or if it just happens to line up timing wise. I will post my code and my a picture of the resulting logs. In my code, each song actually has a few tracks, each with their own audioBufferSource, but only the first one has the onPositionChanged callback.
Player.js
Snack or a link to a repository
https://snack.expo.dev/@gearle/late-audiopositionchanged-cb
React Native Audio API version
0.12.2
React Native version
0.85.3
Platforms
iOS
JavaScript runtime
None
Workflow
Expo Dev Client
Architecture
Fabric (New Architecture)
Build type
Debug app & dev bundle
Device
iOS simulator
Device model
iPhone 15 Simulator
Acknowledgements
Yes