Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

### Fixes

- Fix potential ANR/deadlock in Session Replay when `checkCanRecord` runs on the replay executor thread ([#5837](https://github.com/getsentry/sentry-java/pull/5837))
- Prevent concurrent PixelCopy access during Session Replay masking and bitmap cleanup ([#5808](https://github.com/getsentry/sentry-java/pull/5808))
- Release `MediaMuxer` when the replay video encoder fails to start to avoid a resource leak ([#5607](https://github.com/getsentry/sentry-java/pull/5607))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,11 @@ public class ReplayIntegration(
}
addFrame(bitmap, frameTimeStamp, screen)
}
checkCanRecord()
// Post to the main thread: onScreenshotRecorded can run on the replay executor
// (PixelCopy masked-capture and emit paths), and checkCanRecord -> pauseInternal
// acquires lifecycleLock — if another thread holds that lock while submitting to
// the same executor, we deadlock.
mainLooperHandler.post { checkCanRecord() }
}

override fun onScreenshotRecorded(screenshot: File, frameTimestamp: Long) {
Expand All @@ -375,7 +379,7 @@ public class ReplayIntegration(
}
addFrame(screenshot, frameTimestamp, screen)
}
checkCanRecord()
mainLooperHandler.post { checkCanRecord() }
}

override fun close() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.content.Context
import android.graphics.Bitmap
import android.graphics.Bitmap.CompressFormat.JPEG
import android.graphics.Bitmap.Config.ARGB_8888
import android.os.Looper
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import io.sentry.Breadcrumb
Expand Down Expand Up @@ -73,6 +74,7 @@ import org.mockito.kotlin.reset
import org.mockito.kotlin.times
import org.mockito.kotlin.verify
import org.mockito.kotlin.whenever
import org.robolectric.Shadows.shadowOf
import org.robolectric.annotation.Config

@RunWith(AndroidJUnit4::class)
Expand Down Expand Up @@ -647,6 +649,7 @@ class ReplayIntegrationTest {
replay.register(fixture.scopes, fixture.options)
replay.start()
replay.onScreenshotRecorded(mock<Bitmap>())
shadowOf(Looper.getMainLooper()).idle()

verify(recorder).pause()
}
Expand Down
Loading