Skip to content
Merged
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 sentry-android-replay/api/sentry-android-replay.api
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public final class io/sentry/android/replay/ModifierExtensionsKt {

public abstract interface class io/sentry/android/replay/Recorder : java/io/Closeable {
public abstract fun pause ()V
public abstract fun reset ()V
public abstract fun resume ()V
public abstract fun start (Lio/sentry/android/replay/ScreenshotRecorderConfig;)V
public abstract fun stop ()V
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@ public interface Recorder : Closeable {

public fun pause()

public fun reset()

public fun stop()
}
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,13 @@ public class ReplayIntegration(
return
}

lifecycle.currentState = STARTED
captureStrategy = replayCaptureStrategyProvider?.invoke(isFullSession) ?: if (isFullSession) {
SessionCaptureStrategy(options, scopes, dateProvider, replayExecutor, replayCacheProvider)
} else {
BufferCaptureStrategy(options, scopes, dateProvider, random, replayExecutor, replayCacheProvider)
}

registerRootViewListeners()
lifecycle.currentState = STARTED
}
}

Expand All @@ -213,9 +212,9 @@ public class ReplayIntegration(
return
}

lifecycle.currentState = RESUMED
captureStrategy?.resume()
recorder?.resume()
lifecycle.currentState = RESUMED
}
}

Expand Down Expand Up @@ -268,6 +267,7 @@ public class ReplayIntegration(
}

unregisterRootViewListeners()
recorder?.reset()
recorder?.stop()
gestureRecorder?.stop()
captureStrategy?.stop()
Expand Down Expand Up @@ -320,13 +320,7 @@ public class ReplayIntegration(
return
}

captureStrategy?.stop()
recorder?.let {
it.stop()
if (it is ConfigurationChangedListener) {
it.onConfigurationChanged()
}
}
recorder?.stop()

// once the window size is determined
// onWindowSizeChanged is triggered and we'll start the actual capturing
Expand Down Expand Up @@ -482,7 +476,6 @@ public class ReplayIntegration(
// we have to restart recorder with a new config and pause immediately if the replay is paused
if (lifecycle.currentState == PAUSED) {
recorder?.pause()
captureStrategy?.pause()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ internal class WindowRecorder(
private val windowCallback: WindowCallback,
private val mainLooperHandler: MainLooperHandler,
private val replayExecutor: ScheduledExecutorService
) : Recorder, OnRootViewsChangedListener, ConfigurationChangedListener {
) : Recorder, OnRootViewsChangedListener {

internal companion object {
private const val TAG = "WindowRecorder"
Expand Down Expand Up @@ -130,6 +130,14 @@ internal class WindowRecorder(
recorder?.pause()
}

override fun reset() {
lastKnownWindowSize.set(0, 0)
rootViewsLock.acquire().use {
rootViews.forEach { recorder?.unbind(it.get()) }
rootViews.clear()
}
}

override fun stop() {
recorder?.close()
recorder = null
Expand All @@ -139,19 +147,11 @@ internal class WindowRecorder(
}

override fun close() {
onConfigurationChanged()
reset()
stop()
capturer.gracefullyShutdown(options)
}

override fun onConfigurationChanged() {
lastKnownWindowSize.set(0, 0)
rootViewsLock.acquire().use {
rootViews.forEach { recorder?.unbind(it.get()) }
rootViews.clear()
}
}

private class RecorderExecutorServiceThreadFactory : ThreadFactory {
private var cnt = 0
override fun newThread(r: Runnable): Thread {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,6 @@ internal fun interface OnRootViewsChangedListener {
)
}

internal fun interface ConfigurationChangedListener {
/**
* Called whenever the device configuration changes
*/
fun onConfigurationChanged()
}

/**
* A utility that holds the list of root views that WindowManager updates.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ class ReplayIntegrationWithRecorderTest {
state = PAUSED
}

override fun reset() {
TODO("Not yet implemented")
}

override fun stop() {
state = STOPPED
}
Expand Down
Loading