-
Notifications
You must be signed in to change notification settings - Fork 0
DOC-14148: Limit maximum size of the audio buffer #58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DOC-14148: Limit maximum size of the audio buffer #58
Conversation
if framebuffer.bufferedAudioDuration >= RDMPEGPlayerMaxAudioBufferSize { | ||
return true | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не могу понять что эти изменения делают, так как следом идет проверка на > minSize, который всегда меньше и всегда будет выполняться при выполнении условия на >= maxSize. То есть проверка, по идее, не несет смысла.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Передивився цей ПР. Трохи мене не туди занесло із фіксом. Виглядає так, що краш відбувається в кложурі в якому сильно захоплюється self. Раніше ще думав, що можна додати перевірку на максимальний розмір аудіо буфера, але не думаю що це відноситься до цього краша
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR addresses a potential audio buffer overflow crash in the RDMPEGPlayer by adding weak self references to prevent retain cycles and fixing property access in audio callback closures. The changes ensure proper memory management and thread safety in the audio processing pipeline.
- Adds weak self references to closure parameters to prevent memory leaks
- Replaces direct property access with explicit self references in audio callbacks
- Improves memory safety in audio frame processing methods
@@ -875,7 +877,7 @@ public class RDMPEGPlayer: NSObject { | |||
autoreleasepool { | |||
var outData = outData | |||
|
|||
if videoStreamExist && correctionInfo == nil { | |||
if self.videoStreamExist && self.correctionInfo == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This property access occurs within an audio callback closure but doesn't use weak self capture like other closures in this method. This could lead to a strong reference cycle and potential crashes when the player is deallocated during audio processing.
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only closure here is the autoreleasepool. Self has been properly captured as weak below
@@ -887,7 +889,7 @@ public class RDMPEGPlayer: NSObject { | |||
var numFramesLeft = numFrames | |||
|
|||
while numFramesLeft > 0 { | |||
if rawAudioFrame == nil { | |||
if self.rawAudioFrame == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to line 880, this property access in the audio callback doesn't use weak self capture, which could cause retain cycles and crashes during player deallocation.
Copilot uses AI. Check for mistakes.
Ticket link
DOC-14148
PR description
PR submission checklist