@@ -52,6 +52,7 @@ public class NRMASessionReplay: NSObject {
5252 /// Tracks which frame counter values contain full snapshots
5353 private var fullSnapshotFrameIndices : Set < Int > = [ ]
5454
55+ private let frameQueue = DispatchQueue ( label: " com.newrelic.sessionreplay.frames " )
5556
5657 public var isFirstChunk = true
5758 var uncompressedDataSize : Int = 0
@@ -199,20 +200,24 @@ public class NRMASessionReplay: NSObject {
199200
200201 func addFrame( _ frame: SessionReplayFrame ) {
201202
202- rawFrames. append ( frame)
203-
204- // BEGIN PROCESSING FRAME TO FILE
205- // Process frame to file
206- DispatchQueue . global ( qos: . background) . async { [ weak self] in
203+ frameQueue. async { [ weak self] in
207204 guard let self = self else { return }
205+ self . rawFrames. append ( frame)
208206
209- self . processFrameToFile ( frame)
207+ // BEGIN PROCESSING FRAME TO FILE
208+ // Process frame to file
209+ DispatchQueue . global ( qos: . background) . async { [ weak self] in
210+ guard let self = self else { return }
211+
212+ self . processFrameToFile ( frame)
213+
214+ // END PROCESSING FRAME TO FILE
215+ }
216+
217+ if self . recordingMode == . error {
218+ self . pruneRawFrames ( )
219+ }
210220
211- // END PROCESSING FRAME TO FILE
212- }
213-
214- if recordingMode == . error {
215- pruneRawFrames ( )
216221 }
217222 }
218223
@@ -357,7 +362,6 @@ public class NRMASessionReplay: NSObject {
357362
358363 /// REPLAY PERSISTENCE
359364
360-
361365 func processFrameToFile( _ frame: SessionReplayFrame ) {
362366
363367
0 commit comments