Skip to main content
Version: 1.1.x

SurfaceView Capture

On API 29+, Coryn can capture SurfaceView content, including SurfaceViews hosted in an AndroidView Composable. Use the APIs below to preserve the correct order when surfaces overlap other content.

Set the surface order through Coryn​

After Coryn.init(), use these wrappers in place of the corresponding Android setters:

Coryn APIResult
Coryn.setZOrderOnTop(surface, true)Place the surface above its window content.
Coryn.setZOrderOnTop(surface, false)Place the surface behind its window content.
Coryn.setZOrderMediaOverlay(surface, true)Place it above regular surfaces, while remaining behind window content.
Coryn.setZOrderMediaOverlay(surface, false)Return it to regular surface ordering.

These APIs accept Boolean values, matching Android's setters. They do not accept an integer layer index.

import android.view.SurfaceView
import ai.coryn.replay.api.core.main.Coryn

val preview = SurfaceView(context)
Coryn.setZOrderOnTop(preview, onTop = true)
// Add preview to your UI after configuring its order.

Kotlin extensions are also available:

import ai.coryn.replay.api.core.main.Coryn.corynSetZOrderOnTop
import ai.coryn.replay.api.core.main.Coryn.corynSetZOrderMediaOverlay

preview.corynSetZOrderOnTop(true)
overlayPreview.corynSetZOrderMediaOverlay(true)

Java calls use the same static methods:

Coryn.setZOrderOnTop(preview, true);
Coryn.setZOrderMediaOverlay(overlayPreview, true);

Android version behaviour​

Android APICapture behaviour
23–28SurfaceView content cannot be captured.
29–35Use a Coryn wrapper for every ordering change. Direct Android setter calls can produce incorrect ordering in replay.
36+Direct Android ordering changes are supported, including integer composition ordering. Coryn wrappers remain available for shared code.

Set the order before the containing window is attached. Android also supports changing setZOrderOnTop after attachment on API 30+ when the app targets API 30+. setZOrderMediaOverlay must be configured before attachment. See the Android SurfaceView reference for platform ordering behaviour. Coryn forwards the Android operation; it cannot make an unsupported ordering change take effect.

The wrappers dispatch to the View's UI thread. Configure a new SurfaceView on its owning UI thread before adding it to an attached hierarchy so the ordering operation happens before attachment.

Privacy​

Ordering does not hide surface content. Apply Privacy Masking to a containing View, or to the enclosing Composable for an AndroidView, when the content must be hidden. Include enough padding for content drawn beyond layout bounds.

Do not rely on SurfaceView.setSecure() to hide content from Coryn. Explicitly mark sensitive content for masking; Android may also prevent capture of protected content.

Unavailable frames​

When Android cannot provide a frame, the affected region shows a black “Frame unavailable” placeholder. This can happen before a surface displays its first frame. The placeholder does not indicate that a privacy mask was applied.

On API 23–28, unsupported hardware bitmaps can also show the “Frame unavailable” placeholder.

Other capture failures can cause a snapshot to be skipped. Capture failure diagnostics include integer codes to help identify the failing stage. Reproduce problems with the development Log Viewer available and include the diagnostic code when reporting them.