react-native-skia-webgpu-video 0.1.0-beta.0 → 0.1.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/android/BUILD_VALIDATION.md +1 -1
- package/android/src/main/java/com/azzapp/rnskv/DisplayVsyncPeriod.java +72 -0
- package/android/src/main/java/com/azzapp/rnskv/NativeRgbaBuffer.java +9 -1
- package/android/src/main/java/com/azzapp/rnskv/RgbaBufferAllocator.java +32 -1
- package/android/src/main/java/com/azzapp/rnskv/VideoCompositionDecoder.java +10 -3
- package/android/src/main/java/com/azzapp/rnskv/VideoCompositionFramesExtractor.java +120 -5
- package/docs/UPSTREAM_NOTES.md +2 -0
- package/lib/module/videoCompositionPlayer.js +22 -2
- package/lib/module/videoCompositionPlayer.js.map +1 -1
- package/lib/typescript/src/videoCompositionPlayer.d.ts +23 -1
- package/lib/typescript/src/videoCompositionPlayer.d.ts.map +1 -1
- package/package.json +8 -5
- package/scripts/skia-canvas-patch.json +1 -1
- package/src/videoCompositionPlayer.ts +53 -3
- /package/patches/{react-native-skia+3.7.0.patch → react-native-skia+3.7.1.patch} +0 -0
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<a href="https://github.com/batical/react-native-skia-webgpu-video/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/batical/react-native-skia-webgpu-video/actions/workflows/ci.yml/badge.svg?branch=main" /></a>
|
|
7
7
|
<a href="https://www.npmjs.com/package/react-native-skia-webgpu-video"><img alt="npm" src="https://img.shields.io/npm/v/react-native-skia-webgpu-video/beta" /></a>
|
|
8
8
|
<a href="#status"><img alt="Status: beta" src="https://img.shields.io/badge/status-beta-f59e0b" /></a>
|
|
9
|
-
<img alt="React Native Skia 3.7.
|
|
9
|
+
<img alt="React Native Skia 3.7.1" src="https://img.shields.io/badge/Skia-3.7.1-38bdf8" />
|
|
10
10
|
<img alt="React Native WebGPU 0.17.0" src="https://img.shields.io/badge/WebGPU-0.17.0-a78bfa" />
|
|
11
11
|
<a href="LICENSE"><img alt="MIT license" src="https://img.shields.io/badge/license-MIT-34d399" /></a>
|
|
12
12
|
</p>
|
|
@@ -27,7 +27,7 @@ A new Skia 3 / WebGPU frame-interop layer, written from scratch with explicit re
|
|
|
27
27
|
- **Audio compositions** with clip audio, separate tracks, and per-item volume.
|
|
28
28
|
- **Custom GPU processing** through an export frame processor and an optional WebGPU resource scope.
|
|
29
29
|
|
|
30
|
-
> **Beta.** The
|
|
30
|
+
> **Beta.** The Skia 3.7.0 / WebGPU 0.17.0 build has run on an iPhone 15 Pro and a Pixel 8a (export speed, pixel checks); 3.7.1, which only changes iOS presentation on ProMotion displays, passed the native tests, smoke runs and the Pixel pixel check. Not yet qualified: memory over long sessions (last checked on 3.0.6), HDR, audible output and A/V synchronization; two 4K cases have known issues. See [status](#status) before adopting this in production.
|
|
31
31
|
|
|
32
32
|
## Installation
|
|
33
33
|
|
|
@@ -37,7 +37,7 @@ A new Skia 3 / WebGPU frame-interop layer, written from scratch with explicit re
|
|
|
37
37
|
| --- | --- |
|
|
38
38
|
| React Native | `0.86.2` tested; declared peer range `>=0.83 <0.87` |
|
|
39
39
|
| React | `19.2.3` tested |
|
|
40
|
-
| React Native Skia | **`react-native-skia@3.7.
|
|
40
|
+
| React Native Skia | **`react-native-skia@3.7.1`** |
|
|
41
41
|
| React Native WebGPU | **`react-native-webgpu@0.17.0`** (both resolve `react-native-webgpu-dawn@157.0.0`) |
|
|
42
42
|
| Reanimated / Worklets | **`4.5.3` / `0.11.3`** |
|
|
43
43
|
| Native runtime | New Architecture and Hermes |
|
|
@@ -50,7 +50,7 @@ A native rebuild is required. Expo Go cannot load this module. Skia and WebGPU n
|
|
|
50
50
|
The beta is published on npm under the `beta` tag:
|
|
51
51
|
|
|
52
52
|
```sh
|
|
53
|
-
npm install --save-exact react-native-skia@3.7.
|
|
53
|
+
npm install --save-exact react-native-skia@3.7.1 react-native-webgpu@0.17.0 react-native-reanimated@4.5.3 react-native-worklets@0.11.3
|
|
54
54
|
npm install --save-exact react-native-skia-webgpu-video@beta
|
|
55
55
|
```
|
|
56
56
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Android validation and frame ownership
|
|
2
2
|
|
|
3
|
-
The Android example in `../example/android` pins React Native 0.86.2, Skia 3.7.
|
|
3
|
+
The Android example in `../example/android` pins React Native 0.86.2, Skia 3.7.1, WebGPU 0.17.0, the shared `react-native-webgpu-dawn` 157.0.0 (chrome-m157) and Graphite Android 157.0.0; Gradle needs `node` to resolve that Dawn package. Export renders into encoder-lent AHardwareBuffers (`android/cpp/EncoderTargets.cpp`) sampled into the codec Surface by EGL, with CPU readback as the fallback. On API 29+, 8-bit SDR H.264/HEVC clips decoded at their encoded size go through an `ImageReader`, whose YUV buffers WebGPU converts, crops and rotates; since 3.6.1 each buffer is imported once, and exports sample the converted frame in place. The 3.7.0 build was assembled and run on a Pixel 8a on 2026-10-19 ([verification](../migration/skia-3.7.0/verification.md)), after the 3.6.1 build of 2026-10-16 ([verification](../migration/skia-3.6.1/verification.md)) and the 3.4.4 build of 2026-10-14/15 ([verification](../migration/skia-3.4.4/verification.md)); the evidence below is from Skia 3.0.6 / WebGPU 0.12.1 / Graphite 154.1.0. It uses Java 17, Gradle 9.3.1, Android SDK 36 and NDK 27.1.12297006. The library requires API 28; a consuming application with a lower minimum receives an explicit Gradle configuration error. The default example ABI is arm64-v8a; `RNSKV_ANDROID_ABI` selects another ABI for the validation script.
|
|
4
4
|
|
|
5
5
|
Run `android/scripts/validate.sh build` from the repository. It assembles the example Debug and unsigned Release APKs, library AAR, standalone instrumentation APK and JVM tests. Release uses the installed `hermes-compiler` package, and both native and Metro build concurrency are bounded to two workers. The Release APK is unsigned: device installation requires signing a separate local qualification artifact. The project supplies no publishing or release signing configuration.
|
|
6
6
|
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
package com.azzapp.rnskv;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import android.hardware.display.DisplayManager;
|
|
5
|
+
import android.view.Display;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The vsync period of a display, kept current as its refresh rate changes.
|
|
9
|
+
*
|
|
10
|
+
* Taken from the display rather than from the gaps between vsyncs: those
|
|
11
|
+
* cannot tell a slower refresh rate from missed vsyncs, and an adaptive
|
|
12
|
+
* display dropping from 90 or 120 Hz to 60 Hz left such an estimate at the
|
|
13
|
+
* old rate.
|
|
14
|
+
*/
|
|
15
|
+
final class DisplayVsyncPeriod implements DisplayManager.DisplayListener {
|
|
16
|
+
private final DisplayManager displayManager;
|
|
17
|
+
private final Display display;
|
|
18
|
+
private volatile long periodNanos;
|
|
19
|
+
|
|
20
|
+
private DisplayVsyncPeriod(DisplayManager displayManager, Display display) {
|
|
21
|
+
this.displayManager = displayManager;
|
|
22
|
+
this.display = display;
|
|
23
|
+
update();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Follows the display's refresh rate changes on the calling thread's looper.
|
|
28
|
+
*
|
|
29
|
+
* @param display the display to follow, null for the default one
|
|
30
|
+
* @return null when the display cannot be followed
|
|
31
|
+
*/
|
|
32
|
+
static DisplayVsyncPeriod watch(Context context, Display display) {
|
|
33
|
+
DisplayManager displayManager = context.getSystemService(DisplayManager.class);
|
|
34
|
+
if (displayManager == null) return null;
|
|
35
|
+
if (display == null) display = displayManager.getDisplay(Display.DEFAULT_DISPLAY);
|
|
36
|
+
if (display == null) return null;
|
|
37
|
+
DisplayVsyncPeriod period = new DisplayVsyncPeriod(displayManager, display);
|
|
38
|
+
displayManager.registerDisplayListener(period, null);
|
|
39
|
+
return period;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @return the display's vsync period in nanoseconds, 0 when unknown
|
|
44
|
+
*/
|
|
45
|
+
long getPeriodNanos() {
|
|
46
|
+
return periodNanos;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
void release() {
|
|
50
|
+
displayManager.unregisterDisplayListener(this);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
private void update() {
|
|
54
|
+
float rate = display.getRefreshRate();
|
|
55
|
+
periodNanos = rate > 0 ? (long) (1_000_000_000L / rate) : 0;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
@Override
|
|
59
|
+
public void onDisplayAdded(int displayId) {
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
@Override
|
|
63
|
+
public void onDisplayRemoved(int displayId) {
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@Override
|
|
67
|
+
public void onDisplayChanged(int displayId) {
|
|
68
|
+
if (displayId == display.getDisplayId()) {
|
|
69
|
+
update();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -21,7 +21,15 @@ final class NativeRgbaBuffer {
|
|
|
21
21
|
ByteBuffer::allocateDirect, NativeRgbaBuffer::nativeAlias, size -> {
|
|
22
22
|
Runtime runtime = Runtime.getRuntime();
|
|
23
23
|
RgbaBufferAllocator.checkAllocationCapacity(size, runtime.maxMemory());
|
|
24
|
-
});
|
|
24
|
+
}, NativeRgbaBuffer::collect);
|
|
25
|
+
|
|
26
|
+
/** Collects, then waits for the references it cleared to be enqueued. */
|
|
27
|
+
private static void collect() {
|
|
28
|
+
Runtime.getRuntime().gc();
|
|
29
|
+
// On ART this waits for the reference queue daemon, which enqueues the
|
|
30
|
+
// buffers' phantom references ahead of the finalizers it waits on.
|
|
31
|
+
System.runFinalization();
|
|
32
|
+
}
|
|
25
33
|
|
|
26
34
|
static ByteBuffer allocate(int size) { return allocator.allocate(size); }
|
|
27
35
|
|
|
@@ -14,14 +14,23 @@ final class RgbaBufferAllocator {
|
|
|
14
14
|
private final IntFunction<ByteBuffer> allocateBacking;
|
|
15
15
|
private final Function<ByteBuffer, ByteBuffer> alias;
|
|
16
16
|
private final IntConsumer checkHeap;
|
|
17
|
+
private final Runnable reclaim;
|
|
18
|
+
/** Collections asked for when the native budget refuses a reservation. */
|
|
19
|
+
static final int RECLAIM_ATTEMPTS = 3;
|
|
17
20
|
RgbaBufferAllocator(BufferLifetime lifetimes, IntToLongFunction reserve, LongConsumer release,
|
|
18
21
|
IntFunction<ByteBuffer> allocateBacking, Function<ByteBuffer, ByteBuffer> alias) {
|
|
19
22
|
this(lifetimes, reserve, release, allocateBacking, alias, size -> {});
|
|
20
23
|
}
|
|
21
24
|
RgbaBufferAllocator(BufferLifetime lifetimes, IntToLongFunction reserve, LongConsumer release,
|
|
22
25
|
IntFunction<ByteBuffer> allocateBacking, Function<ByteBuffer, ByteBuffer> alias, IntConsumer checkHeap) {
|
|
26
|
+
this(lifetimes, reserve, release, allocateBacking, alias, checkHeap, () -> {});
|
|
27
|
+
}
|
|
28
|
+
RgbaBufferAllocator(BufferLifetime lifetimes, IntToLongFunction reserve, LongConsumer release,
|
|
29
|
+
IntFunction<ByteBuffer> allocateBacking, Function<ByteBuffer, ByteBuffer> alias, IntConsumer checkHeap,
|
|
30
|
+
Runnable reclaim) {
|
|
23
31
|
this.lifetimes = lifetimes; this.reserve = reserve; this.release = release;
|
|
24
32
|
this.allocateBacking = allocateBacking; this.alias = alias; this.checkHeap = checkHeap;
|
|
33
|
+
this.reclaim = reclaim;
|
|
25
34
|
}
|
|
26
35
|
|
|
27
36
|
/** Refuse a single backing too large for ART's heap and cleanup headroom.
|
|
@@ -44,7 +53,7 @@ final class RgbaBufferAllocator {
|
|
|
44
53
|
ByteBuffer allocate(int size) {
|
|
45
54
|
lifetimes.drain();
|
|
46
55
|
checkHeap.accept(size);
|
|
47
|
-
long token =
|
|
56
|
+
long token = reserveReclaiming(size);
|
|
48
57
|
Allocation owner;
|
|
49
58
|
try {
|
|
50
59
|
owner = new Allocation();
|
|
@@ -79,5 +88,27 @@ final class RgbaBufferAllocator {
|
|
|
79
88
|
lifetimes.track(exposed, owner, 0);
|
|
80
89
|
return exposed;
|
|
81
90
|
}
|
|
91
|
+
/** A buffer holds its reservation until the GC finds it unreachable. A fast
|
|
92
|
+
* decode drops a frame per vsync, 8 MB each in 1080p, and those dead buffers
|
|
93
|
+
* filled the native budget before the Java heap asked for a collection: the
|
|
94
|
+
* budget refused frames nobody held. Refused while buffers are tracked, the
|
|
95
|
+
* reservation is retried after a collection has returned theirs. */
|
|
96
|
+
private long reserveReclaiming(int size) {
|
|
97
|
+
try {
|
|
98
|
+
return reserve.applyAsLong(size);
|
|
99
|
+
} catch (RuntimeException refused) {
|
|
100
|
+
RuntimeException last = refused;
|
|
101
|
+
for (int attempt = 0; attempt < RECLAIM_ATTEMPTS && lifetimes.trackedCount() > 0; attempt++) {
|
|
102
|
+
reclaim.run();
|
|
103
|
+
lifetimes.drain();
|
|
104
|
+
try {
|
|
105
|
+
return reserve.applyAsLong(size);
|
|
106
|
+
} catch (RuntimeException again) {
|
|
107
|
+
last = again;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
throw last;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
82
113
|
private static final class Allocation { ByteBuffer backing; }
|
|
83
114
|
}
|
|
@@ -114,15 +114,22 @@ public class VideoCompositionDecoder {
|
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
private void prepareCurrent(long positionUs) {
|
|
117
|
+
if (realTime) {
|
|
118
|
+
// The codecs call back on their own thread, lazy or not. Left to default
|
|
119
|
+
// they call back on the looper of the thread that configures them, and
|
|
120
|
+
// the preview prepares from the UI thread: every buffer of every item,
|
|
121
|
+
// and the burst after each seek (a loop's wrap, a seam), then queued on
|
|
122
|
+
// the main looper ahead of the frame that draws them.
|
|
123
|
+
callbackThread = new HandlerThread("ReactNativeSkiaVideo-Codecs");
|
|
124
|
+
callbackThread.start();
|
|
125
|
+
callbacks = new Handler(callbackThread.getLooper());
|
|
126
|
+
}
|
|
117
127
|
if (realTime && window.isLazy()) {
|
|
118
128
|
// Opening a codec takes tens of milliseconds: not on the thread that
|
|
119
129
|
// draws, nor the one that plays, nor the one the playing codec calls back on.
|
|
120
130
|
openerThread = new HandlerThread("ReactNativeSkiaVideo-Opener");
|
|
121
131
|
openerThread.start();
|
|
122
132
|
opener = new Handler(openerThread.getLooper());
|
|
123
|
-
callbackThread = new HandlerThread("ReactNativeSkiaVideo-Codecs");
|
|
124
|
-
callbackThread.start();
|
|
125
|
-
callbacks = new Handler(callbackThread.getLooper());
|
|
126
133
|
}
|
|
127
134
|
for (VideoComposition.Item item : composition.getItems()) {
|
|
128
135
|
if (!item.isVideo() || !opens(item, positionUs)) {
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
package com.azzapp.rnskv;
|
|
2
2
|
|
|
3
|
+
import android.app.Activity;
|
|
3
4
|
import android.os.Handler;
|
|
4
5
|
import android.os.HandlerThread;
|
|
5
6
|
import android.os.Message;
|
|
6
7
|
import android.os.Process;
|
|
7
8
|
import android.os.SystemClock;
|
|
8
9
|
import android.util.Log;
|
|
10
|
+
import android.view.Choreographer;
|
|
9
11
|
|
|
10
12
|
import androidx.media3.common.util.UnstableApi;
|
|
11
13
|
|
|
14
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
15
|
+
|
|
12
16
|
import java.io.IOException;
|
|
13
17
|
import java.util.Map;
|
|
18
|
+
import java.util.concurrent.atomic.AtomicBoolean;
|
|
14
19
|
import javax.microedition.khronos.egl.EGLContext;
|
|
15
20
|
import javax.microedition.khronos.egl.EGL10;
|
|
16
21
|
|
|
@@ -27,6 +32,7 @@ public class VideoCompositionFramesExtractor {
|
|
|
27
32
|
private static final int PLAYBACK_LOOP = 4;
|
|
28
33
|
private static final int PLAYBACK_SEEK = 5;
|
|
29
34
|
private static final int PLAYBACK_RELEASE = 6;
|
|
35
|
+
private static final int PLAYBACK_VSYNC_RELEASE = 7;
|
|
30
36
|
|
|
31
37
|
private final VideoComposition composition;
|
|
32
38
|
|
|
@@ -48,13 +54,46 @@ public class VideoCompositionFramesExtractor {
|
|
|
48
54
|
|
|
49
55
|
|
|
50
56
|
private long pendingSeek = 0;
|
|
51
|
-
|
|
57
|
+
// Read on the thread that collects frames (see releaseForNextVsync), written on the playback thread.
|
|
58
|
+
private volatile boolean isPlaying = false;
|
|
52
59
|
|
|
53
|
-
private long startTime = 0;
|
|
54
|
-
private long pausePosition = 0;
|
|
60
|
+
private volatile long startTime = 0;
|
|
61
|
+
private volatile long pausePosition = 0;
|
|
55
62
|
private boolean isEOS = false;
|
|
56
63
|
private boolean completeDispatched = false;
|
|
57
64
|
|
|
65
|
+
// Vsync-aligned release, written and read on the thread that collects frames.
|
|
66
|
+
private long lastVsyncNanos = 0;
|
|
67
|
+
private long recordedVsyncNanos = 0;
|
|
68
|
+
private boolean recordingVsync = false;
|
|
69
|
+
/** Notes each vsync's timestamp on the collecting thread, for as long as the preview lives. */
|
|
70
|
+
private final Choreographer.FrameCallback vsyncRecorder = new Choreographer.FrameCallback() {
|
|
71
|
+
@Override
|
|
72
|
+
public void doFrame(long frameTimeNanos) {
|
|
73
|
+
if (releasing) {
|
|
74
|
+
unwatchDisplay();
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
recordedVsyncNanos = frameTimeNanos;
|
|
78
|
+
Choreographer.getInstance().postFrameCallback(this);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
// The display the preview is on; null until the first collection, or when unknown.
|
|
82
|
+
private DisplayVsyncPeriod vsyncPeriod;
|
|
83
|
+
// When that thread last released frames; the playback loop stands back meanwhile.
|
|
84
|
+
private volatile long lastVsyncReleaseNanos = 0;
|
|
85
|
+
// The release itself runs on the playback thread: the decoder's locks are held
|
|
86
|
+
// there for whole codec flushes on a seek, and the UI thread must never
|
|
87
|
+
// wait on them (measured: 65 ms frames when it did).
|
|
88
|
+
private volatile long vsyncReleasePosition = 0;
|
|
89
|
+
private final AtomicBoolean vsyncReleasePosted = new AtomicBoolean(false);
|
|
90
|
+
|
|
91
|
+
private void vsyncReleaseInternal() {
|
|
92
|
+
vsyncReleasePosted.set(false);
|
|
93
|
+
decoder.render(vsyncReleasePosition);
|
|
94
|
+
}
|
|
95
|
+
private static final long VSYNC_RELEASE_TIMEOUT_NANOS = 100_000_000L;
|
|
96
|
+
|
|
58
97
|
/**
|
|
59
98
|
* Create a new VideoCompositionFramesExtractor.
|
|
60
99
|
*
|
|
@@ -117,7 +156,76 @@ public class VideoCompositionFramesExtractor {
|
|
|
117
156
|
* when finished, without affecting the producer or other snapshots
|
|
118
157
|
*/
|
|
119
158
|
public Map<String, VideoFrame> decodeCompositionFrames() {
|
|
120
|
-
|
|
159
|
+
Map<String, VideoFrame> frames = decoder.updateVideosFrames();
|
|
160
|
+
releaseForNextVsync();
|
|
161
|
+
return frames;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Releases the decoded frames the next vsync is due to show, from the thread
|
|
166
|
+
* that collects them, right after collecting.
|
|
167
|
+
*
|
|
168
|
+
* The playback loop released them on its 10 ms tick, out of phase with the
|
|
169
|
+
* display, so whether a frame was collected on the vsync after its time or
|
|
170
|
+
* the one after that was chance: 24 fps on a 60 Hz display came out in
|
|
171
|
+
* 17/67 ms steps among the 33/50 ms it implies. Released against the vsync's
|
|
172
|
+
* own timestamp, one vsync ahead, every frame is collected on the first
|
|
173
|
+
* vsync at or after its time. The position is decided here, against the
|
|
174
|
+
* vsync; the release is posted to the playback thread, a vsync ahead of the
|
|
175
|
+
* collection that needs it.
|
|
176
|
+
*/
|
|
177
|
+
private void releaseForNextVsync() {
|
|
178
|
+
if (!recordingVsync) {
|
|
179
|
+
try {
|
|
180
|
+
// The collecting thread is a Choreographer thread (the UI thread).
|
|
181
|
+
Choreographer.getInstance().postFrameCallback(vsyncRecorder);
|
|
182
|
+
recordingVsync = true;
|
|
183
|
+
} catch (RuntimeException e) {
|
|
184
|
+
// No looper on this thread: leave the release to the playback loop.
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
watchDisplay();
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
long period = vsyncPeriod != null ? vsyncPeriod.getPeriodNanos() : 0;
|
|
191
|
+
if (period == 0 || recordedVsyncNanos == 0) return;
|
|
192
|
+
// This frame's vsync, whether the recorder has run in this frame yet or not.
|
|
193
|
+
long since = Math.max(0, System.nanoTime() - recordedVsyncNanos);
|
|
194
|
+
long vsyncNanos = recordedVsyncNanos + (since / period) * period;
|
|
195
|
+
if (vsyncNanos == lastVsyncNanos) return;
|
|
196
|
+
lastVsyncNanos = vsyncNanos;
|
|
197
|
+
long vsyncPeriodNanos = period;
|
|
198
|
+
long position = isPlaying
|
|
199
|
+
? (vsyncNanos + vsyncPeriodNanos) / 1000 - startTime
|
|
200
|
+
: pausePosition;
|
|
201
|
+
lastVsyncReleaseNanos = System.nanoTime();
|
|
202
|
+
vsyncReleasePosition = position;
|
|
203
|
+
if (vsyncReleasePosted.compareAndSet(false, true)) {
|
|
204
|
+
// A message, not a posted runnable: it goes through handleMessage's
|
|
205
|
+
// releasing check and turns a throw into an error event.
|
|
206
|
+
handler.sendEmptyMessage(PLAYBACK_VSYNC_RELEASE);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Follows the refresh rate of the display the preview is on, from the
|
|
212
|
+
* collecting thread, whose looper then receives its changes. Without a React
|
|
213
|
+
* context (instrumented tests) the period stays unknown and the playback loop
|
|
214
|
+
* releases on its tick.
|
|
215
|
+
*/
|
|
216
|
+
private void watchDisplay() {
|
|
217
|
+
ReactApplicationContext context = ReactNativeSkiaVideoModule.currentReactApplicationContext();
|
|
218
|
+
if (context == null) return;
|
|
219
|
+
Activity activity = context.getCurrentActivity();
|
|
220
|
+
vsyncPeriod = DisplayVsyncPeriod.watch(context,
|
|
221
|
+
activity != null ? activity.getWindowManager().getDefaultDisplay() : null);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
private void unwatchDisplay() {
|
|
225
|
+
if (vsyncPeriod != null) {
|
|
226
|
+
vsyncPeriod.release();
|
|
227
|
+
vsyncPeriod = null;
|
|
228
|
+
}
|
|
121
229
|
}
|
|
122
230
|
|
|
123
231
|
/**
|
|
@@ -241,7 +349,10 @@ public class VideoCompositionFramesExtractor {
|
|
|
241
349
|
completeDispatched = false;
|
|
242
350
|
}
|
|
243
351
|
decoder.updateWindow(currentPosition);
|
|
244
|
-
|
|
352
|
+
if (System.nanoTime() - lastVsyncReleaseNanos > VSYNC_RELEASE_TIMEOUT_NANOS) {
|
|
353
|
+
// No one collecting at vsync (not yet, or no longer): release on the tick.
|
|
354
|
+
decoder.render(currentPosition);
|
|
355
|
+
}
|
|
245
356
|
if (isEOS && looping) {
|
|
246
357
|
playInternal();
|
|
247
358
|
}
|
|
@@ -329,6 +440,10 @@ public class VideoCompositionFramesExtractor {
|
|
|
329
440
|
releaseInternal();
|
|
330
441
|
return true;
|
|
331
442
|
}
|
|
443
|
+
case PLAYBACK_VSYNC_RELEASE -> {
|
|
444
|
+
vsyncReleaseInternal();
|
|
445
|
+
return true;
|
|
446
|
+
}
|
|
332
447
|
default -> {
|
|
333
448
|
return false;
|
|
334
449
|
}
|
package/docs/UPSTREAM_NOTES.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Points amont à revoir lors d'une mise à jour Skia
|
|
2
2
|
|
|
3
|
+
**Mise à jour du 20 octobre 2026 :** **`react-native-skia@3.7.1`**, toujours avec `react-native-webgpu@0.17.0` et Dawn/Graphite 157.0.0. La 3.7.1 ne contient qu'une correction iOS ([#4273](https://github.com/wcandillon/react-native-skia/pull/4273)) : `SkiaView.mm` présente désormais à la pleine fréquence de l'écran sur les appareils ProMotion. Les sept fichiers modifiés par le patch local sont identiques octet pour octet à ceux de la 3.7.0 : le patch s'applique tel quel, seuls sa version et son nom changent. Nos PR amont [#4274](https://github.com/wcandillon/react-native-skia/pull/4274), [#4275](https://github.com/wcandillon/react-native-skia/pull/4275) et [#4276](https://github.com/wcandillon/react-native-skia/pull/4276) sont encore ouvertes : le patch ne rétrécit pas. Vérifié le 20 octobre sur appareils, en Release : iPhone 15 Pro, tests natifs 50/50 et profil smoke 15/15 (l'app déclare Skia 3.7.1, écran à 120 Hz) ; Pixel 8a, contrôle `interop` 10/10 (erreur maximale par canal de 1, comme en 3.7.0, chemins GPU et readback d'accord à l'export) et smoke 15/15. Les mesures d'export de la 3.7.0 restent la référence : le code d'export ne change pas.
|
|
4
|
+
|
|
3
5
|
**Migration du 19 octobre 2026 :** le code et les dépendances déclarées ciblent désormais **`react-native-skia@3.7.0` / `react-native-webgpu@0.17.0`**, sur Graphite **157.0.0** et **`react-native-webgpu-dawn@157.0.0`** (Skia `chrome/m157`). Les deux paquets doivent monter ensemble : Gradle et le podspec refusent deux Dawn différents. Le patch local garde 61 de ses 62 éditions ; seule tombe l'include `<stdexcept>`, désormais présent en amont. Le Dawn 157 demande trois images FIFO à la swapchain Android, ce qui supprime l'attente du thread principal dans `dequeueBuffer` sur Android 10 ; il garde aussi la robustesse des shaders sur Android, nos WGSL compris. L'[audit](../migration/skia-3.7.0/upstream-audit.md) détaille ces changements ; la [vérification](../migration/skia-3.7.0/verification.md) donne les mesures sur iPhone 15 Pro et Pixel 8a. Après une mise à jour, supprimer le bundle JS généré par Gradle avant de construire un APK de qualification : sa tâche ne voit pas le `node_modules` racine.
|
|
4
6
|
|
|
5
7
|
**Migration du 16 octobre 2026 :** le code et les dépendances déclarées ciblaient alors **`react-native-skia@3.6.1` / `react-native-webgpu@0.16.0`**, toujours sur Graphite **154.3.0** et **`react-native-webgpu-dawn@154.3.0`** : les binaires Skia et Dawn ne changent pas. L'[audit](../migration/skia-3.6.1/upstream-audit.md) détaille les changements amont, la régression de couleurs des frames décodées Android introduite par WebGPU 0.15 et sa correction, puis l'import en place à l'export Android. La [vérification](../migration/skia-3.6.1/verification.md) donne les mesures sur iPhone 15 Pro et Pixel 8a. **À chaque mise à jour WebGPU, relancer le contrôle `interop` du Pixel** : il compare les pixels décodés et exportés au chemin CPU, et c'est lui qui a révélé cette régression.
|
|
@@ -24,6 +24,8 @@ export const useVideoComposition = ({
|
|
|
24
24
|
autoPlay = false,
|
|
25
25
|
isLooping = false,
|
|
26
26
|
drawWhenPaused = false,
|
|
27
|
+
redrawOnTime,
|
|
28
|
+
splitImportAndDraw = false,
|
|
27
29
|
onReadyToPlay,
|
|
28
30
|
onComplete,
|
|
29
31
|
onError
|
|
@@ -161,6 +163,10 @@ export const useVideoComposition = ({
|
|
|
161
163
|
const lastDrawnFramesVersion = useSharedValue(-1);
|
|
162
164
|
const lastDrawnTime = useSharedValue(-1);
|
|
163
165
|
const lastDrawnInputs = useSharedValue(null);
|
|
166
|
+
// Frames version whose new frames the previous vsyncs already imported.
|
|
167
|
+
const lastImportedVersion = useSharedValue(-1);
|
|
168
|
+
// Whether the previous vsync imported and left its draw to this one.
|
|
169
|
+
const drawDeferred = useSharedValue(false);
|
|
164
170
|
// A new drawFrame can draw something else from the same time and frames.
|
|
165
171
|
useEffect(() => {
|
|
166
172
|
lastDrawnTime.value = -1;
|
|
@@ -206,6 +212,18 @@ export const useVideoComposition = ({
|
|
|
206
212
|
sourcesGeneration.value = generation;
|
|
207
213
|
const currentTime = framesExtractor.currentTime;
|
|
208
214
|
const framesVersion = framesExtractor.framesVersion;
|
|
215
|
+
if (splitImportAndDraw && framesVersion !== lastImportedVersion.value) {
|
|
216
|
+
// ownVideoFrames above has just imported the new frames: leave the
|
|
217
|
+
// draw to the next vsync, which finds them in the import cache. Never
|
|
218
|
+
// twice running: a frame that lands on the vsync owed a draw would
|
|
219
|
+
// push it again, and the frame before it would never be shown.
|
|
220
|
+
lastImportedVersion.value = framesVersion;
|
|
221
|
+
if (!drawDeferred.value && currentFrame.value !== null && frameGeneration.value === generation) {
|
|
222
|
+
drawDeferred.value = true;
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
drawDeferred.value = false;
|
|
209
227
|
const inputs = Array.isArray(drawWhenPaused) ? drawWhenPaused : null;
|
|
210
228
|
let inputsSame = true;
|
|
211
229
|
if (inputs) {
|
|
@@ -219,8 +237,10 @@ export const useVideoComposition = ({
|
|
|
219
237
|
}
|
|
220
238
|
}
|
|
221
239
|
}
|
|
222
|
-
|
|
223
|
-
|
|
240
|
+
// A negative last time means a redraw was requested (a new drawFrame).
|
|
241
|
+
const timeSame = currentTime === lastDrawnTime.value || redrawOnTime !== undefined && lastDrawnTime.value >= 0 && !redrawOnTime(lastDrawnTime.value, currentTime);
|
|
242
|
+
if (drawWhenPaused !== true && inputsSame && (!framesExtractor.isPlaying || redrawOnTime !== undefined) && currentFrame.value !== null && frameGeneration.value === generation && framesVersion === lastDrawnFramesVersion.value && timeSame && surfaceWidth.value === pixelWidth && surfaceHeight.value === pixelHeight) {
|
|
243
|
+
// Nothing new to show: the image on screen is still exact, and
|
|
224
244
|
// redrawing it at every vsync would only burn GPU time and battery.
|
|
225
245
|
return;
|
|
226
246
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getVideoCanvas","BlendMode","Skia","useSharedValue","useFrameCallback","runOnUI","useCallback","useEffect","useRef","useState","RNSkiaVideoModule","useEventListener","PixelRatio","scheduleOnRN","ownVideoFrames","releaseVideoFrameImage","frameByteSize","reserveVideoMemory","disposePreviewResources","useVideoComposition","composition","drawFrame","beforeDrawFrame","afterDrawFrame","width","height","autoPlay","isLooping","drawWhenPaused","onReadyToPlay","onComplete","onError","failedComposition","setFailedComposition","isErrored","session","setSession","framesExtractor","extractor","generation","nextGeneration","activeOnRN","activeGeneration","frameGeneration","sourcesGeneration","currentFrame","pendingSnapshot","pendingAfterDraw","previousSources","onCreationError","current","created","createVideoCompositionFramesExtractor","error","createdGeneration","value","releasePreview","failure","native","failed","console","warn","retry","errorHandler","isCurrentSession","prepare","play","surfaceSharedValue","canvasSharedValue","surfaceReservation","surfaceWidth","surfaceHeight","resources","surface","canvas","images","frames","Object","values","reservation","afterDraw","run","lastDrawnFramesVersion","lastDrawnTime","lastDrawnInputs","pixelRatio","get","pixelWidth","Math","floor","pixelHeight","isFinite","decodeCompositionFrames","key","previous","entries","producerId","currentTime","framesVersion","inputs","Array","isArray","inputsSame","last","length","i","isPlaying","retired","retiredFailure","Surface","MakeOffscreen","Error","drawColor","Color","Clear","context","drawn","submitted","undefined","releaseContext","videoComposition","next","makeImageSnapshot","flush","modify","dispose","map","input","player"],"sourceRoot":"../../src","sources":["videoCompositionPlayer.ts"],"mappings":";;AAAA,SAASA,cAAc,QAAQ,aAAU;AAEzC,SAASC,SAAS,EAAEC,IAAI,QAAQ,mBAAmB;AACnD,SACEC,cAAc,EACdC,gBAAgB,EAChBC,OAAO,QAGF,yBAAyB;AAChC,SAASC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAOhE,OAAOC,iBAAiB,MAAM,wBAAqB;AACnD,OAAOC,gBAAgB,MAAM,6BAA0B;AACvD,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,YAAY,QAAQ,uBAAuB;AACpD,SAASC,cAAc,EAAEC,sBAAsB,QAAQ,mBAAgB;AACvE,SAASC,aAAa,EAAEC,kBAAkB,QAAQ,aAAU;AAC5D,SAASC,uBAAuB,QAAQ,uBAAoB;AAoF5D;AACA;AACA;AACA,OAAO,MAAMC,mBAAmB,GAAGA,CAAgB;EACjDC,WAAW;EACXC,SAAS;EACTC,eAAe;EACfC,cAAc;EACdC,KAAK;EACLC,MAAM;EACNC,QAAQ,GAAG,KAAK;EAChBC,SAAS,GAAG,KAAK;EACjBC,cAAc,GAAG,KAAK;EACtBC,aAAa;EACbC,UAAU;EACVC;AACmC,CAAC,KAA0C;EAC9E,MAAM,CAACC,iBAAiB,EAAEC,oBAAoB,CAAC,GAC7CxB,QAAQ,CAA0B,IAAI,CAAC;EACzC,MAAMyB,SAAS,GAAGd,WAAW,KAAK,IAAI,IAAIY,iBAAiB,KAAKZ,WAAW;EAC3E,MAAM,CAACe,OAAO,EAAEC,UAAU,CAAC,GAAG3B,QAAQ,CAI5B,IAAI,CAAC;EACf,MAAM4B,e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,CAACzD,MAAM,GAAG,IAAI;UACrB;QACF;MACF;MACA,IAAIyD,KAAK,CAACzD,MAAM,EAAE,MAAMyD,KAAK,CAAC/D,KAAK;MACnC6B,sBAAsB,CAAC3B,KAAK,GAAG2C,aAAa;MAC5Cf,aAAa,CAAC5B,KAAK,GAAG0C,WAAW;MACjC,IAAIE,MAAM,EAAEf,eAAe,CAAC7B,KAAK,GAAG4C,MAAM,CAAC2B,GAAG,CAAEC,KAAK,IAAKA,KAAK,CAACxE,KAAK,CAAC;IACxE,CAAC,CAAC,OAAOF,KAAK,EAAE;MACdX,gBAAgB,CAACa,KAAK,GAAG,CAAC;MAC1B1C,YAAY,CAACkD,YAAY,EAAEV,KAAK,CAAC;IACnC;EACF,CAAC,EAAE,IAAI,CAAC;EAER,OAAO;IACLR,YAAY;IACZmF,MAAM,EAAE3F;EACV,CAAC;AACH,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["getVideoCanvas","BlendMode","Skia","useSharedValue","useFrameCallback","runOnUI","useCallback","useEffect","useRef","useState","RNSkiaVideoModule","useEventListener","PixelRatio","scheduleOnRN","ownVideoFrames","releaseVideoFrameImage","frameByteSize","reserveVideoMemory","disposePreviewResources","useVideoComposition","composition","drawFrame","beforeDrawFrame","afterDrawFrame","width","height","autoPlay","isLooping","drawWhenPaused","redrawOnTime","splitImportAndDraw","onReadyToPlay","onComplete","onError","failedComposition","setFailedComposition","isErrored","session","setSession","framesExtractor","extractor","generation","nextGeneration","activeOnRN","activeGeneration","frameGeneration","sourcesGeneration","currentFrame","pendingSnapshot","pendingAfterDraw","previousSources","onCreationError","current","created","createVideoCompositionFramesExtractor","error","createdGeneration","value","releasePreview","failure","native","failed","console","warn","retry","errorHandler","isCurrentSession","prepare","play","surfaceSharedValue","canvasSharedValue","surfaceReservation","surfaceWidth","surfaceHeight","resources","surface","canvas","images","frames","Object","values","reservation","afterDraw","run","lastDrawnFramesVersion","lastDrawnTime","lastDrawnInputs","lastImportedVersion","drawDeferred","pixelRatio","get","pixelWidth","Math","floor","pixelHeight","isFinite","decodeCompositionFrames","key","previous","entries","producerId","currentTime","framesVersion","inputs","Array","isArray","inputsSame","last","length","i","timeSame","undefined","isPlaying","retired","retiredFailure","Surface","MakeOffscreen","Error","drawColor","Color","Clear","context","drawn","submitted","releaseContext","videoComposition","next","makeImageSnapshot","flush","modify","dispose","map","input","player"],"sourceRoot":"../../src","sources":["videoCompositionPlayer.ts"],"mappings":";;AAAA,SAASA,cAAc,QAAQ,aAAU;AAEzC,SAASC,SAAS,EAAEC,IAAI,QAAQ,mBAAmB;AACnD,SACEC,cAAc,EACdC,gBAAgB,EAChBC,OAAO,QAGF,yBAAyB;AAChC,SAASC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAOhE,OAAOC,iBAAiB,MAAM,wBAAqB;AACnD,OAAOC,gBAAgB,MAAM,6BAA0B;AACvD,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,YAAY,QAAQ,uBAAuB;AACpD,SAASC,cAAc,EAAEC,sBAAsB,QAAQ,mBAAgB;AACvE,SAASC,aAAa,EAAEC,kBAAkB,QAAQ,aAAU;AAC5D,SAASC,uBAAuB,QAAQ,uBAAoB;AA0G5D;AACA;AACA;AACA,OAAO,MAAMC,mBAAmB,GAAGA,CAAgB;EACjDC,WAAW;EACXC,SAAS;EACTC,eAAe;EACfC,cAAc;EACdC,KAAK;EACLC,MAAM;EACNC,QAAQ,GAAG,KAAK;EAChBC,SAAS,GAAG,KAAK;EACjBC,cAAc,GAAG,KAAK;EACtBC,YAAY;EACZC,kBAAkB,GAAG,KAAK;EAC1BC,aAAa;EACbC,UAAU;EACVC;AACmC,CAAC,KAA0C;EAC9E,MAAM,CAACC,iBAAiB,EAAEC,oBAAoB,CAAC,GAC7C1B,QAAQ,CAA0B,IAAI,CAAC;EACzC,MAAM2B,SAAS,GAAGhB,WAAW,KAAK,IAAI,IAAIc,iBAAiB,KAAKd,WAAW;EAC3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C;IACnC;EACF,CAAC,EAAE,IAAI,CAAC;EAER,OAAO;IACLR,YAAY;IACZsF,MAAM,EAAE9F;EACV,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -51,6 +51,28 @@ type UseVideoCompositionPlayerOptions<T = undefined> = {
|
|
|
51
51
|
* @default false
|
|
52
52
|
*/
|
|
53
53
|
drawWhenPaused?: boolean | SharedValue<unknown>[];
|
|
54
|
+
/**
|
|
55
|
+
* Whether `drawFrame` can draw something different at `currentTime` than it
|
|
56
|
+
* drew at `previousTime` from the same decoded frames. By default every time
|
|
57
|
+
* change redraws, so a playing player draws at every vsync even though the
|
|
58
|
+
* video only changes at its own frame rate. A drawer whose picture depends on
|
|
59
|
+
* time only through the frames (or only at known moments, a transition say)
|
|
60
|
+
* returns false elsewhere, and the player then redraws when a new frame is
|
|
61
|
+
* decoded instead. Ignored when `drawWhenPaused` is `true`, which redraws at
|
|
62
|
+
* every vsync. Must be a worklet.
|
|
63
|
+
*/
|
|
64
|
+
redrawOnTime?: (previousTime: number, currentTime: number) => boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Import a newly decoded frame in one vsync and draw it in the next, instead
|
|
67
|
+
* of both in the same one. On Android the import (YUV blit and its checked
|
|
68
|
+
* GPU wait) and the draw (snapshot and its checked GPU wait) cost about as
|
|
69
|
+
* much as each other, and together they overrun a 90–120 Hz frame budget on
|
|
70
|
+
* the UI thread. The option applies on iOS too. The picture then trails the
|
|
71
|
+
* clock by one vsync. The first frame of a session is still drawn as soon
|
|
72
|
+
* as it is imported.
|
|
73
|
+
* @default false
|
|
74
|
+
*/
|
|
75
|
+
splitImportAndDraw?: boolean;
|
|
54
76
|
/**
|
|
55
77
|
* Callback that is called when the composition is ready to play.
|
|
56
78
|
*/
|
|
@@ -80,6 +102,6 @@ type UseVideoCompositionPlayerReturnType = {
|
|
|
80
102
|
/**
|
|
81
103
|
* A hook that creates a video composition player.
|
|
82
104
|
*/
|
|
83
|
-
export declare const useVideoComposition: <T = undefined>({ composition, drawFrame, beforeDrawFrame, afterDrawFrame, width, height, autoPlay, isLooping, drawWhenPaused, onReadyToPlay, onComplete, onError, }: UseVideoCompositionPlayerOptions<T>) => UseVideoCompositionPlayerReturnType;
|
|
105
|
+
export declare const useVideoComposition: <T = undefined>({ composition, drawFrame, beforeDrawFrame, afterDrawFrame, width, height, autoPlay, isLooping, drawWhenPaused, redrawOnTime, splitImportAndDraw, onReadyToPlay, onComplete, onError, }: UseVideoCompositionPlayerOptions<T>) => UseVideoCompositionPlayerReturnType;
|
|
84
106
|
export {};
|
|
85
107
|
//# sourceMappingURL=videoCompositionPlayer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"videoCompositionPlayer.d.ts","sourceRoot":"","sources":["../../../src/videoCompositionPlayer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAY,OAAO,EAAa,MAAM,mBAAmB,CAAC;AAEtE,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,WAAW,EACjB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EACV,WAAW,EAEX,gBAAgB,EAChB,+BAA+B,EAChC,MAAM,YAAS,CAAC;AASjB,KAAK,gCAAgC,CAAC,CAAC,GAAG,SAAS,IAAI;IACrD;;;OAGG;IACH,WAAW,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACrC;;OAEG;IACH,SAAS,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;IAC1B;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC,CAAC;IAC1B;;;;OAIG;IACH,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,IAAI,CAAC;IACtC;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;;;;;;;;O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pu-video",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.2",
|
|
4
4
|
"description": "Bounded video composition, playback and export for React Native Skia 3 / Graphite",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"types": "./lib/typescript/src/index.d.ts",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"!**/.*",
|
|
41
41
|
"scripts/apply-skia-canvas-patch.mjs",
|
|
42
42
|
"scripts/skia-canvas-patch.json",
|
|
43
|
-
"patches/react-native-skia+3.7.
|
|
43
|
+
"patches/react-native-skia+3.7.1.patch",
|
|
44
44
|
"docs/UPSTREAM_NOTES.md",
|
|
45
45
|
"!ios/tests",
|
|
46
46
|
"!android/src/androidTest",
|
|
@@ -59,7 +59,10 @@
|
|
|
59
59
|
"benchmark:compare": "node scripts/benchmark-compare.mjs",
|
|
60
60
|
"benchmark:inventory": "node scripts/benchmark-inventory.mjs",
|
|
61
61
|
"benchmark:fixtures": "node scripts/benchmark-fixture-manifest.mjs",
|
|
62
|
-
"test:package": "node --test test/package/*.test.mjs"
|
|
62
|
+
"test:package": "node --test test/package/*.test.mjs",
|
|
63
|
+
"release": "node scripts/release.mjs",
|
|
64
|
+
"release:notes": "node scripts/release-notes.mjs",
|
|
65
|
+
"ship": "node scripts/ship.mjs"
|
|
63
66
|
},
|
|
64
67
|
"keywords": [
|
|
65
68
|
"react-native",
|
|
@@ -98,7 +101,7 @@
|
|
|
98
101
|
"react-native": "0.86.2",
|
|
99
102
|
"react-native-builder-bob": "^0.43.0",
|
|
100
103
|
"react-native-reanimated": "4.5.3",
|
|
101
|
-
"react-native-skia": "3.7.
|
|
104
|
+
"react-native-skia": "3.7.1",
|
|
102
105
|
"react-native-webgpu": "0.17.0",
|
|
103
106
|
"react-native-worklets": "0.11.3",
|
|
104
107
|
"react-test-renderer": "19.2.3",
|
|
@@ -108,7 +111,7 @@
|
|
|
108
111
|
"react": ">=19",
|
|
109
112
|
"react-native": ">=0.83 <0.87",
|
|
110
113
|
"react-native-reanimated": "4.5.3",
|
|
111
|
-
"react-native-skia": "3.7.
|
|
114
|
+
"react-native-skia": "3.7.1",
|
|
112
115
|
"react-native-webgpu": "0.17.0",
|
|
113
116
|
"react-native-worklets": "0.11.3"
|
|
114
117
|
},
|
|
@@ -73,6 +73,28 @@ type UseVideoCompositionPlayerOptions<T = undefined> = {
|
|
|
73
73
|
* @default false
|
|
74
74
|
*/
|
|
75
75
|
drawWhenPaused?: boolean | SharedValue<unknown>[];
|
|
76
|
+
/**
|
|
77
|
+
* Whether `drawFrame` can draw something different at `currentTime` than it
|
|
78
|
+
* drew at `previousTime` from the same decoded frames. By default every time
|
|
79
|
+
* change redraws, so a playing player draws at every vsync even though the
|
|
80
|
+
* video only changes at its own frame rate. A drawer whose picture depends on
|
|
81
|
+
* time only through the frames (or only at known moments, a transition say)
|
|
82
|
+
* returns false elsewhere, and the player then redraws when a new frame is
|
|
83
|
+
* decoded instead. Ignored when `drawWhenPaused` is `true`, which redraws at
|
|
84
|
+
* every vsync. Must be a worklet.
|
|
85
|
+
*/
|
|
86
|
+
redrawOnTime?: (previousTime: number, currentTime: number) => boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Import a newly decoded frame in one vsync and draw it in the next, instead
|
|
89
|
+
* of both in the same one. On Android the import (YUV blit and its checked
|
|
90
|
+
* GPU wait) and the draw (snapshot and its checked GPU wait) cost about as
|
|
91
|
+
* much as each other, and together they overrun a 90–120 Hz frame budget on
|
|
92
|
+
* the UI thread. The option applies on iOS too. The picture then trails the
|
|
93
|
+
* clock by one vsync. The first frame of a session is still drawn as soon
|
|
94
|
+
* as it is imported.
|
|
95
|
+
* @default false
|
|
96
|
+
*/
|
|
97
|
+
splitImportAndDraw?: boolean;
|
|
76
98
|
/**
|
|
77
99
|
* Callback that is called when the composition is ready to play.
|
|
78
100
|
*/
|
|
@@ -118,6 +140,8 @@ export const useVideoComposition = <T = undefined>({
|
|
|
118
140
|
autoPlay = false,
|
|
119
141
|
isLooping = false,
|
|
120
142
|
drawWhenPaused = false,
|
|
143
|
+
redrawOnTime,
|
|
144
|
+
splitImportAndDraw = false,
|
|
121
145
|
onReadyToPlay,
|
|
122
146
|
onComplete,
|
|
123
147
|
onError,
|
|
@@ -291,6 +315,10 @@ export const useVideoComposition = <T = undefined>({
|
|
|
291
315
|
const lastDrawnFramesVersion = useSharedValue(-1);
|
|
292
316
|
const lastDrawnTime = useSharedValue(-1);
|
|
293
317
|
const lastDrawnInputs = useSharedValue<unknown[] | null>(null);
|
|
318
|
+
// Frames version whose new frames the previous vsyncs already imported.
|
|
319
|
+
const lastImportedVersion = useSharedValue(-1);
|
|
320
|
+
// Whether the previous vsync imported and left its draw to this one.
|
|
321
|
+
const drawDeferred = useSharedValue(false);
|
|
294
322
|
// A new drawFrame can draw something else from the same time and frames.
|
|
295
323
|
useEffect(() => {
|
|
296
324
|
lastDrawnTime.value = -1;
|
|
@@ -356,6 +384,22 @@ export const useVideoComposition = <T = undefined>({
|
|
|
356
384
|
sourcesGeneration.value = generation;
|
|
357
385
|
const currentTime = framesExtractor.currentTime;
|
|
358
386
|
const framesVersion = framesExtractor.framesVersion;
|
|
387
|
+
if (splitImportAndDraw && framesVersion !== lastImportedVersion.value) {
|
|
388
|
+
// ownVideoFrames above has just imported the new frames: leave the
|
|
389
|
+
// draw to the next vsync, which finds them in the import cache. Never
|
|
390
|
+
// twice running: a frame that lands on the vsync owed a draw would
|
|
391
|
+
// push it again, and the frame before it would never be shown.
|
|
392
|
+
lastImportedVersion.value = framesVersion;
|
|
393
|
+
if (
|
|
394
|
+
!drawDeferred.value &&
|
|
395
|
+
currentFrame.value !== null &&
|
|
396
|
+
frameGeneration.value === generation
|
|
397
|
+
) {
|
|
398
|
+
drawDeferred.value = true;
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
drawDeferred.value = false;
|
|
359
403
|
const inputs = Array.isArray(drawWhenPaused) ? drawWhenPaused : null;
|
|
360
404
|
let inputsSame = true;
|
|
361
405
|
if (inputs) {
|
|
@@ -370,18 +414,24 @@ export const useVideoComposition = <T = undefined>({
|
|
|
370
414
|
}
|
|
371
415
|
}
|
|
372
416
|
}
|
|
417
|
+
// A negative last time means a redraw was requested (a new drawFrame).
|
|
418
|
+
const timeSame =
|
|
419
|
+
currentTime === lastDrawnTime.value ||
|
|
420
|
+
(redrawOnTime !== undefined &&
|
|
421
|
+
lastDrawnTime.value >= 0 &&
|
|
422
|
+
!redrawOnTime(lastDrawnTime.value, currentTime));
|
|
373
423
|
if (
|
|
374
424
|
drawWhenPaused !== true &&
|
|
375
425
|
inputsSame &&
|
|
376
|
-
!framesExtractor.isPlaying &&
|
|
426
|
+
(!framesExtractor.isPlaying || redrawOnTime !== undefined) &&
|
|
377
427
|
currentFrame.value !== null &&
|
|
378
428
|
frameGeneration.value === generation &&
|
|
379
429
|
framesVersion === lastDrawnFramesVersion.value &&
|
|
380
|
-
|
|
430
|
+
timeSame &&
|
|
381
431
|
surfaceWidth.value === pixelWidth &&
|
|
382
432
|
surfaceHeight.value === pixelHeight
|
|
383
433
|
) {
|
|
384
|
-
//
|
|
434
|
+
// Nothing new to show: the image on screen is still exact, and
|
|
385
435
|
// redrawing it at every vsync would only burn GPU time and battery.
|
|
386
436
|
return;
|
|
387
437
|
}
|
|
File without changes
|