diff --git a/apps/benchmark/App.tsx b/apps/benchmark/App.tsx index c974c3f..27228b5 100644 --- a/apps/benchmark/App.tsx +++ b/apps/benchmark/App.tsx @@ -2,7 +2,7 @@ // whole matrix by itself and prints one `[bench] tick ...` line per second to // logcat; bench/run.mjs pairs those with host-side CPU and PSS samples. import React, { useEffect, useMemo, useRef, useState } from 'react'; -import { Linking, StyleSheet, Text as RNText, View } from 'react-native'; +import { Linking, PixelRatio, StyleSheet, Text as RNText, View } from 'react-native'; import { Easing, cancelAnimation, @@ -22,11 +22,13 @@ import { Rect as TgfxRect, Shader as TgfxShader, Text as TgfxText, + Vertices as TgfxVertices, TgfxImage, renderToImage, } from 'react-native-tgfx'; import { Canvas as SkCanvas, + Circle as SkCircle, Fill as SkFill, Group as SkGroup, Image as SkImageView, @@ -47,7 +49,10 @@ import { BG, CX, CY, H, PALETTE, SHAPES, W } from './layout'; // react-native-skia 3.x has one canvas, on Graphite. const ENGINES = ['tgfx', 'skia'] as const; -const SCENES = ['shapes', 'images', 'shader', 'pattern', 'paths', 'text', ...ANIM_SCENES] as const; +// `shapes` pits each engine's fastest static path against the other: tgfx nodes, +// skia's ShapeBlob. `shapes-nodes` and `shapes-atlas` hold the technique equal: +// 20k declarative nodes on both, or one sprite atlas and one tinted mesh on both. +const SCENES = ['shapes', 'shapes-nodes', 'shapes-atlas', 'images', 'shader', 'pattern', 'paths', 'text', ...ANIM_SCENES] as const; // surface: tgfx composite="layer", skia backingView SurfaceView. // texture: tgfx composite="texture", skia backingView TextureView (its default). const VIEWS = ['surface', 'texture'] as const; @@ -198,6 +203,47 @@ function tgfxTextureScene(i: number, size: number) { ); } +// `shapes-atlas` for tgfx: ShapeBlob's technique through the public API. One +// white circle and one white rect, rasterized once at the device scale, side by +// side in a two-cell atlas; every shape is a quad tinted by its vertex colour. +const ATLAS_PX = SHAPES[0].size * PixelRatio.get(); +const ATLAS_CELL = Math.ceil(ATLAS_PX) + 2; + +function tgfxAtlasScene() { + const r = ATLAS_PX / 2; + return ( + <> + + + + ); +} + +// Two triangles per shape, padded by one device pixel on each side so the +// atlas cell's antialiased edge is inside the quad. +let atlasMesh: { vertices: { x: number; y: number }[]; textures: { x: number; y: number }[]; colors: string[] } | null = null; +function tgfxAtlasMesh() { + if (atlasMesh != null) return atlasMesh; + const pad = 1 / PixelRatio.get(); + const vertices: { x: number; y: number }[] = []; + const textures: { x: number; y: number }[] = []; + const colors: string[] = []; + for (const s of SHAPES) { + const x0 = s.x - pad; + const y0 = s.y - pad; + const x1 = s.x + s.size + pad; + const y1 = s.y + s.size + pad; + const u0 = s.circle ? 0 : ATLAS_CELL; + const u1 = u0 + ATLAS_PX + 2; + const v1 = ATLAS_PX + 2; + vertices.push({ x: x0, y: y0 }, { x: x1, y: y0 }, { x: x1, y: y1 }, { x: x0, y: y0 }, { x: x1, y: y1 }, { x: x0, y: y1 }); + textures.push({ x: u0, y: 0 }, { x: u1, y: 0 }, { x: u1, y: v1 }, { x: u0, y: 0 }, { x: u1, y: v1 }, { x: u0, y: v1 }); + for (let k = 0; k < 6; k += 1) colors.push(s.color); + } + atlasMesh = { vertices, textures, colors }; + return atlasMesh; +} + // ---- scenes ---------------------------------------------------------------- function TgfxScene({ @@ -205,14 +251,27 @@ function TgfxScene({ t, images, tile, + atlas, }: { scene: string; t: ReturnType>; images: TgfxImage[]; tile: TgfxImage | null; + atlas: TgfxImage | null; }) { const origin = { x: CX, y: CY }; - if (scene === 'shapes') { + if (scene === 'shapes-atlas') { + if (atlas == null) return null; + const mesh = tgfxAtlasMesh(); + return ( + + + + + + ); + } + if (scene === 'shapes' || scene === 'shapes-nodes') { return ( {SHAPES.map((s, i) => @@ -291,6 +350,19 @@ function SkiaScene({ const patternTransform = useDerivedValue(() => [{ rotate: t.value }, { scale: 0.03 }]); const uniforms = useDerivedValue(() => ({ uTime: t.value, uSize: [W, H] })); const origin = vec(CX, CY); + if (scene === 'shapes-nodes') { + return ( + + {SHAPES.map((s, i) => + s.circle ? ( + + ) : ( + + ) + )} + + ); + } if (scene === 'images') { if (images.length < 8) return null; return ( @@ -358,6 +430,7 @@ export default function App() { const [combo, setCombo] = useState(0); const [tgfxImages, setTgfxImages] = useState([]); const [tgfxTile, setTgfxTile] = useState(null); + const [tgfxAtlas, setTgfxAtlas] = useState(null); const [plan, setPlan] = useState(null); const [gapMs, setGapMs] = useState(0); // anim-imp for tgfx: which thread writes the 20k handles (bench://run?...&imp=js). @@ -396,9 +469,12 @@ export default function App() { built.push(await renderToImage(tgfxTextureScene(i, 128), { width: 128, height: 128 })); } const builtTile = await renderToImage(tgfxTextureScene(2, 64), { width: 64, height: 64 }); + // Here, not in the scene: renderToImage needs no canvas mounted around it. + const builtAtlas = await renderToImage(tgfxAtlasScene(), { width: ATLAS_CELL * 2, height: ATLAS_CELL }); if (!alive) return; setTgfxImages(built); setTgfxTile(builtTile); + setTgfxAtlas(builtAtlas); })(); return () => { alive = false; @@ -519,7 +595,7 @@ export default function App() { {isAnim(scene) ? ( ) : ( - + )} ) @@ -533,7 +609,7 @@ export default function App() { deviceIndependentFonts={scene === 'text' && dif} > - {scene === 'shapes' ? ( + {scene === 'shapes' || scene === 'shapes-atlas' ? ( ) : isAnim(scene) ? ( diff --git a/apps/benchmark/README.md b/apps/benchmark/README.md index 8dd9711..9505db7 100644 --- a/apps/benchmark/README.md +++ b/apps/benchmark/README.md @@ -12,12 +12,21 @@ Static scenes: 20,000 shapes, 3,600 images, a 40-octave full-screen shader, a repeating image pattern, 10,000 cubic paths (half stroked) and 6,000 texts, each under one animated rotation driven by a shared value. `paths` runs any other path count (`paths900` is the scene the tables before 2026-11-10 used; both -engines sit at 120 fps on it on a current flagship). +engines sit at 120 fps on it on a current flagship). The default matrix runs +`paths900`, `paths2500`, `paths5000` and `paths` (10,000), so a table shows +where each engine falls off. Skia draws the static shapes through `Skia.ShapeBlob` + `drawShapes` (3.10), recorded once into a picture: its explicit batched-shape API, the counterpart of the batching tgfx does internally for plain ``/`` nodes. The -unbatched Skia path is the `shapes-picture` row. +unbatched Skia path is the `shapes-picture` row. Two more rows hold the +technique equal: + +| scene | tgfx | skia | +|---|---|---| +| `shapes` | 20,000 ``/`` nodes | one ShapeBlob | +| `shapes-nodes` | 20,000 ``/`` nodes | 20,000 ``/`` nodes | +| `shapes-atlas` | a white circle and rect rasterized once into an atlas, 20,000 tinted quads in one `` | one ShapeBlob (the same technique, built in) | Per-shape scenes (`AnimScenes.tsx`): every shape orbits its own home on its own phase and speed, so no transform can be shared and tgfx's draw reordering @@ -56,7 +65,7 @@ app and the rows stop. | flag | default | | |---|---|---| | `--engines` | `tgfx,skia` | engine order; `skia,tgfx` runs skia first | -| `--scenes` | all nine | subset, e.g. `paths,anim-imp`, or `paths2500` for another path count | +| `--scenes` | all fourteen | subset, e.g. `paths,anim-imp`, or `paths7500` for another path count | | `--views` | `surface,texture` | outer loop of the matrix | | `--skip` | none | `engine:scene` pairs to leave out, e.g. `tgfx:anim-imp` | | `--order` | `sequential` | `alternate` runs every engine per scene | diff --git a/apps/benchmark/bench/results-2026-11-11-samsung-90hz-skia310-raw.md b/apps/benchmark/bench/results-2026-11-11-samsung-90hz-skia310-raw.md new file mode 100644 index 0000000..15f0b74 --- /dev/null +++ b/apps/benchmark/bench/results-2026-11-11-samsung-90hz-skia310-raw.md @@ -0,0 +1,135 @@ +# Raw: Samsung SM-E146B, 90 Hz, react-native-skia 3.10.0 + +`node bench/run.mjs --order alternate --reps 2 --gap 10 --cool 0.95 --cool-timeout 240 --skip tgfx:anim-imp --views `, once per view. + +## SurfaceView + +| engine · scene · view | Present FPS | UI FPS | JS FPS | CPU % (1 core = 100) | PSS MB | thermal | CPU cap % | ticks | +|---|---|---|---|---|---|---|---|---| +| tgfx · shapes · surface | 61.3 | 90 | 90 | 189 | 389.5 | 2 | 68 | 53 | +| skia · shapes · surface | 89.4 | 91 | 91 | 70 | 322.4 | 2 | 100 | 53 | +| tgfx · shapes-nodes · surface | 62.3 | 91 | 90 | 184 | 389.6 | 2 | 80 | 53 | +| skia · shapes-nodes · surface | 26.1 | 91 | 90 | 95 | 454.1 | 2 | 100 | 53 | +| tgfx · shapes-atlas · surface | 90.0 | 91 | 91 | 48 | 369.3 | 2 | 100 | 52 | +| skia · shapes-atlas · surface | 89.4 | 91 | 91 | 70 | 320.7 | 2 | 100 | 52 | +| tgfx · images · surface | 90.1 | 91 | 91 | 78 | 335.7 | 2 | 100 | 53 | +| skia · images · surface | 88.1 | 91 | 91 | 111 | 344.7 | 2 | 92 | 53 | +| tgfx · shader · surface | 15.0 | 91 | 91 | 25 | 329.4 | 2 | 100 | 53 | +| skia · shader · surface | 14.8 | 91 | 91 | 28 | 305.6 | 2 | 100 | 53 | +| tgfx · pattern · surface | 90.1 | 91 | 91 | 46 | 325.9 | 1 | 100 | 53 | +| skia · pattern · surface | 89.6 | 91 | 91 | 58 | 300.7 | 1 | 100 | 53 | +| tgfx · paths900 · surface | 90.3 | 91 | 91 | 76 | 348.6 | 0 | 100 | 53 | +| skia · paths900 · surface | 27.2 | 91 | 90 | 52 | 405.5 | 0 | 100 | 53 | +| tgfx · paths2500 · surface | 82.6 | 91 | 90 | 113 | 380.4 | 0 | 98 | 52 | +| skia · paths2500 · surface | 27.1 | 91 | 90 | 60 | 413.6 | 0 | 100 | 53 | +| tgfx · paths5000 · surface | 43.8 | 91 | 90 | 111 | 489.8 | 0 | 100 | 53 | +| skia · paths5000 · surface | 17.8 | 91 | 90 | 53 | 430.1 | 0 | 100 | 53 | +| tgfx · paths · surface | 8.8 | 91 | 90 | 167 | 521.9 | 0 | 100 | 53 | +| skia · paths · surface | 10.3 | 91 | 91 | 47 | 453.7 | 0 | 100 | 53 | +| tgfx · text · surface | 73.0 | 91 | 90 | 128 | 362.0 | 0 | 100 | 53 | +| skia · text · surface | 32.4 | 91 | 91 | 122 | 402.5 | 0 | 100 | 53 | +| tgfx · anim-decl · surface | 24.6 | 34 | 17 | 224 | 500.1 | 0 | 92 | 51 | +| skia · anim-decl · surface | 32.3 | 32 | 16 | 143 | 474.6 | 0 | 98 | 51 | +| skia · anim-imp · surface | 54.9 | 79 | 40 | 162 | 358.6 | 0 | 95 | 51 | +| tgfx · shapes-picture · surface | 83.1 | 91 | 90 | 145 | 392.3 | 0 | 98 | 53 | +| skia · shapes-picture · surface | 26.1 | 91 | 90 | 84 | 420.4 | 0 | 100 | 53 | + +`thermal` is the highest Android thermal status (0 none … 3 severe) seen at the start of the combo's runs. `CPU cap %` is the lowest scaling_max_freq / cpuinfo_max_freq seen during them: below 100 the kernel was throttling, whatever the status says. + +### Where the CPU and memory go + +| engine · scene · view | UI thread % | JS thread % | busiest other threads % | Graphics MB | Native MB | Java MB | +|---|---|---|---|---|---|---| +| tgfx · shapes · surface | 7 | 2 | TgfxRender 150, nitro-thread 18, binder 6 | 161.1 | 142.2 | 4.0 | +| skia · shapes · surface | 8 | 2 | RNSkia Present 24, RNSkia Render 16, binder 7 | 134.9 | 106.5 | 4.8 | +| tgfx · shapes-nodes · surface | 7 | 2 | TgfxRender 148, nitro-thread 18, binder 6 | 161.1 | 141.7 | 4.4 | +| skia · shapes-nodes · surface | 6 | 1 | RNSkia Render 57, RNSkia Present 22, binder 4 | 239.4 | 118.5 | 4.6 | +| tgfx · shapes-atlas · surface | 10 | 2 | TgfxRender 17, binder 7, mali-cmar-backe 7 | 149.4 | 124.9 | 4.4 | +| skia · shapes-atlas · surface | 8 | 2 | RNSkia Present 23, RNSkia Render 16, mali-cmar-backe 7 | 134.9 | 105.9 | 4.8 | +| tgfx · images · surface | 7 | 1 | TgfxRender 54, binder 5, mali-cmar-backe 5 | 143.4 | 111.7 | 4.4 | +| skia · images · surface | 6 | 1 | RNSkia Render 58, RNSkia Present 37, binder 5 | 150.4 | 110.8 | 4.8 | +| tgfx · shader · surface | 12 | 3 | binder 4, TgfxRender 4, mali-cmar-backe 1 | 145.1 | 104.7 | 4.4 | +| skia · shader · surface | 12 | 3 | RNSkia Present 5, binder 3, mali-cmar-backe 1 | 119.8 | 103.5 | 4.5 | +| tgfx · pattern · surface | 10 | 2 | TgfxRender 15, binder 7, mali-cmar-backe 6 | 143.3 | 104.3 | 4.4 | +| skia · pattern · surface | 9 | 2 | RNSkia Present 24, binder 7, mali-cmar-backe 7 | 118.1 | 102.1 | 4.8 | +| tgfx · paths900 · surface | 7 | 1 | TgfxRender 53, binder 5, mali-cmar-backe 4 | 158.0 | 112.3 | 4.4 | +| skia · paths900 · surface | 12 | 3 | RNSkia Render 13, RNSkia Present 11, mali-cmar-backe 5 | 219.4 | 103.6 | 4.6 | +| tgfx · paths2500 · surface | 6 | 1 | TgfxRender 95, binder 6, mali-cmar-backe 3 | 175.8 | 123.2 | 4.4 | +| skia · paths2500 · surface | 11 | 3 | RNSkia Render 27, RNSkia Present 9, mali-cmar-backe 4 | 224.4 | 104.6 | 4.6 | +| tgfx · paths5000 · surface | 6 | 1 | TgfxRender 98, binder 5, mali-cmar-backe 2 | 259.1 | 148.6 | 4.4 | +| skia · paths5000 · surface | 11 | 3 | RNSkia Render 25, RNSkia Present 6, mali-cmar-backe 4 | 230.5 | 109.5 | 4.5 | +| tgfx · paths · surface | 6 | 1 | TgfxRender 144, nitro-thread 13, binder 4 | 241.5 | 186.6 | 4.4 | +| skia · paths · surface | 11 | 3 | RNSkia Render 22, RNSkia Present 4, mali-cmar-backe 4 | 251.4 | 109.7 | 4.5 | +| tgfx · text · surface | 6 | 1 | TgfxRender 101, nitro-thread 11, binder 5 | 151.5 | 128.8 | 4.4 | +| skia · text · surface | 5 | 1 | RNSkia Render 93, RNSkia Present 17, binder 4 | 195.3 | 118.3 | 4.6 | +| tgfx · anim-decl · surface | 97 | 0 | TgfxRender 98, nitro-thread 15, binder 4 | 152.6 | 189.0 | 4.4 | +| skia · anim-decl · surface | 98 | 0 | RNSkia Render 27, RNSkia Present 15, binder 4 | 141.3 | 177.1 | 4.5 | +| skia · anim-imp · surface | 97 | 1 | RNSkia Render 33, RNSkia Present 26, binder 6 | 153.9 | 123.5 | 4.6 | +| tgfx · shapes-picture · surface | 6 | 1 | TgfxRender 121, nitro-thread 13, binder 4 | 161.1 | 144.5 | 4.4 | +| skia · shapes-picture · surface | 7 | 2 | RNSkia Render 44, RNSkia Present 24, binder 4 | 230.1 | 113.0 | 4.5 | + +## TextureView + +| engine · scene · view | Present FPS | UI FPS | JS FPS | CPU % (1 core = 100) | PSS MB | thermal | CPU cap % | ticks | +|---|---|---|---|---|---|---|---|---| +| tgfx · shapes · texture | 56.4 | 90 | 90 | 202 | 421.2 | 2 | 80 | 53 | +| skia · shapes · texture | 89.1 | 91 | 91 | 87 | 337.7 | 2 | 100 | 53 | +| tgfx · shapes-nodes · texture | 54.6 | 90 | 90 | 200 | 424.5 | 2 | 80 | 53 | +| skia · shapes-nodes · texture | 25.4 | 91 | 90 | 101 | 491.6 | 2 | 98 | 52 | +| tgfx · shapes-atlas · texture | 88.1 | 91 | 91 | 76 | 401.4 | 2 | 100 | 53 | +| skia · shapes-atlas · texture | 89.1 | 91 | 91 | 88 | 338.6 | 2 | 98 | 53 | +| tgfx · images · texture | 88.8 | 91 | 91 | 99 | 368.0 | 2 | 98 | 53 | +| skia · images · texture | 85.1 | 91 | 90 | 134 | 364.6 | 2 | 84 | 53 | +| tgfx · shader · texture | 12.6 | 45 | 44 | 22 | 364.7 | 2 | 100 | 51 | +| skia · shader · texture | 14.3 | 33 | 31 | 23 | 326.0 | 2 | 100 | 51 | +| tgfx · pattern · texture | 89.0 | 91 | 91 | 77 | 358.6 | 2 | 100 | 53 | +| skia · pattern · texture | 88.9 | 91 | 91 | 77 | 318.5 | 2 | 76 | 53 | +| tgfx · paths900 · texture | 88.4 | 91 | 90 | 95 | 378.9 | 2 | 92 | 53 | +| skia · paths900 · texture | 26.6 | 66 | 65 | 52 | 426.3 | 2 | 100 | 51 | +| tgfx · paths2500 · texture | 72.5 | 91 | 90 | 132 | 472.1 | 2 | 80 | 53 | +| skia · paths2500 · texture | 26.3 | 68 | 66 | 62 | 436.2 | 2 | 100 | 51 | +| tgfx · paths5000 · texture | 41.4 | 91 | 90 | 121 | 515.5 | 2 | 80 | 53 | +| skia · paths5000 · texture | 17.6 | 72 | 70 | 53 | 448.2 | 2 | 100 | 51 | +| tgfx · paths · texture | 4.8 | 90 | 90 | 204 | 545.9 | 2 | 80 | 53 | +| skia · paths · texture | 10.1 | 79 | 78 | 47 | 477.6 | 2 | 100 | 52 | +| tgfx · text · texture | 65.4 | 90 | 90 | 146 | 392.5 | 2 | 80 | 53 | +| skia · text · texture | 30.3 | 88 | 86 | 131 | 420.0 | 2 | 92 | 51 | +| tgfx · anim-decl · texture | 11.6 | 30 | 16 | 216 | 530.5 | 2 | 72 | 51 | +| skia · anim-decl · texture | 9.4 | 32 | 16 | 116 | 484.1 | 2 | 88 | 51 | +| skia · anim-imp · texture | 21.9 | 76 | 39 | 129 | 374.6 | 2 | 88 | 52 | +| tgfx · shapes-picture · texture | 69.3 | 90 | 90 | 171 | 425.2 | 2 | 88 | 53 | +| skia · shapes-picture · texture | 25.3 | 91 | 90 | 91 | 463.4 | 2 | 100 | 52 | + +`thermal` is the highest Android thermal status (0 none … 3 severe) seen at the start of the combo's runs. `CPU cap %` is the lowest scaling_max_freq / cpuinfo_max_freq seen during them: below 100 the kernel was throttling, whatever the status says. + +### Where the CPU and memory go + +| engine · scene · view | UI thread % | JS thread % | busiest other threads % | Graphics MB | Native MB | Java MB | +|---|---|---|---|---|---|---| +| tgfx · shapes · texture | 10 | 2 | TgfxRender 148, nitro-thread 19, RenderThread 11 | 195.3 | 142.0 | 4.4 | +| skia · shapes · texture | 11 | 2 | RenderThread 20, RNSkia Present 17, RNSkia Render 15 | 149.9 | 106.8 | 4.7 | +| tgfx · shapes-nodes · texture | 10 | 2 | TgfxRender 144, nitro-thread 18, RenderThread 11 | 195.3 | 144.3 | 4.4 | +| skia · shapes-nodes · texture | 8 | 1 | RNSkia Render 57, RNSkia Present 23, mali-cmar-backe 4 | 277.3 | 119.7 | 4.5 | +| tgfx · shapes-atlas · texture | 13 | 2 | RenderThread 23, TgfxRender 15, mali-cmar-backe 13 | 183.6 | 125.4 | 4.4 | +| skia · shapes-atlas · texture | 11 | 2 | RenderThread 20, RNSkia Present 17, RNSkia Render 15 | 155.9 | 106.6 | 4.7 | +| tgfx · images · texture | 10 | 1 | TgfxRender 48, RenderThread 19, mali-cmar-backe 10 | 177.5 | 112.3 | 4.4 | +| skia · images · texture | 9 | 1 | RNSkia Render 60, RNSkia Present 40, RenderThread 14 | 171.3 | 111.2 | 4.7 | +| tgfx · shader · texture | 6 | 2 | RenderThread 4, TgfxRender 4, binder 4 | 183.2 | 105.2 | 4.4 | +| skia · shader · texture | 4 | 1 | RNSkia Present 4, RenderThread 4, mali-cmar-backe 3 | 144.8 | 103.8 | 4.4 | +| tgfx · pattern · texture | 12 | 2 | RenderThread 22, TgfxRender 14, mali-cmar-backe 13 | 177.4 | 105.1 | 4.4 | +| skia · pattern · texture | 11 | 2 | RenderThread 20, RNSkia Present 17, mali-cmar-backe 11 | 138.9 | 102.4 | 4.7 | +| tgfx · paths900 · texture | 10 | 2 | TgfxRender 52, RenderThread 17, mali-cmar-backe 9 | 191.2 | 112.3 | 4.4 | +| skia · paths900 · texture | 9 | 2 | RNSkia Render 12, RenderThread 8, RNSkia Present 8 | 244.8 | 103.8 | 4.5 | +| tgfx · paths2500 · texture | 10 | 1 | TgfxRender 95, RenderThread 13, mali-cmar-backe 7 | 266.2 | 124.1 | 4.4 | +| skia · paths2500 · texture | 8 | 2 | RNSkia Render 26, RNSkia Present 7, RenderThread 7 | 249.7 | 105.6 | 4.5 | +| tgfx · paths5000 · texture | 8 | 1 | TgfxRender 96, RenderThread 7, binder 4 | 291.7 | 143.3 | 4.4 | +| skia · paths5000 · texture | 8 | 2 | RNSkia Render 25, mali-cmar-backe 5, RNSkia Present 5 | 256.1 | 110.1 | 4.5 | +| tgfx · paths · texture | 7 | 1 | TgfxRender 151, nitro-thread 17, binder 4 | 268.8 | 185.9 | 4.4 | +| skia · paths · texture | 9 | 2 | RNSkia Render 22, mali-cmar-backe 4, binder 3 | 278.6 | 110.7 | 4.4 | +| tgfx · text · texture | 9 | 1 | TgfxRender 106, RenderThread 11, nitro-thread 9 | 185.7 | 129.0 | 4.4 | +| skia · text · texture | 6 | 1 | RNSkia Render 95, RNSkia Present 16, RenderThread 5 | 219.0 | 118.4 | 4.5 | +| tgfx · anim-decl · texture | 96 | 0 | TgfxRender 100, nitro-thread 9, RenderThread 3 | 186.6 | 189.0 | 4.4 | +| skia · anim-decl · texture | 98 | 0 | RNSkia Render 7, RNSkia Present 4, binder 3 | 148.7 | 177.9 | 4.4 | +| skia · anim-imp · texture | 97 | 1 | RNSkia Render 12, RNSkia Present 8, RenderThread 4 | 173.3 | 124.6 | 4.5 | +| tgfx · shapes-picture · texture | 10 | 2 | TgfxRender 122, nitro-thread 15, RenderThread 13 | 196.4 | 144.1 | 4.4 | +| skia · shapes-picture · texture | 8 | 1 | RNSkia Render 43, RNSkia Present 25, mali-cmar-backe 5 | 273.6 | 113.6 | 4.5 | diff --git a/apps/benchmark/bench/results-2026-11-11-samsung-90hz-skia310.md b/apps/benchmark/bench/results-2026-11-11-samsung-90hz-skia310.md new file mode 100644 index 0000000..97f1b27 --- /dev/null +++ b/apps/benchmark/bench/results-2026-11-11-samsung-90hz-skia310.md @@ -0,0 +1,83 @@ +# tgfx vs react-native-skia 3.10.0 on a mid-range phone + +Samsung SM-E146B (Exynos 1330, Mali-G68, Android 15, 1080x2408, 90 Hz), +release build, Hermes, new architecture. react-native-tgfx from source (tgfx +submodule `1b2a429`), react-native-skia 3.10.0 from npm. + +`node bench/run.mjs --order alternate --reps 2 --gap 10 --cool 0.95 --cool-timeout 240 --skip tgfx:anim-imp`, +one view at a time. + +Every combo ran twice, each time in a fresh process started once the CPU +frequency cap was back above 95 %. Present FPS is the median of the four 8 s +windows (two per run), counted at SurfaceFlinger. Raw output: +`results-2026-11-11-samsung-90hz-skia310-raw.md`. + +## Present FPS + +| scene | tgfx surface | skia surface | tgfx texture | skia texture | +|---|---|---|---|---| +| shapes, 20k (tgfx nodes, skia ShapeBlob) | 61.3 | **89.4** | 56.4 | **89.1** | +| shapes-nodes, 20k nodes on both | **62.3** | 26.1 | **54.6** | 25.4 | +| shapes-atlas, one atlas on both | 90.0 | 89.4 | 88.1 | 89.1 | +| shapes-picture, 20k draws recorded once | **83.1** | 26.1 | **69.3** | 25.3 | +| images, 3,600 | 90.1 | 88.1 | 88.8 | 85.1 | +| shader | 15.0 | 14.8 | 12.6 | 14.3 | +| pattern | 90.1 | 89.6 | 89.0 | 88.9 | +| paths, 900 | **90.3** | 27.2 | **88.4** | 26.6 | +| paths, 2,500 | **82.6** | 27.1 | **72.5** | 26.3 | +| paths, 5,000 | **43.8** | 17.8 | **41.4** | 17.6 | +| paths, 10,000 | 8.8 | 10.3 | 4.8 | **10.1** | +| text, 6,000 (skia `deviceIndependentFonts`) | **73.0** | 32.4 | **65.4** | 30.3 | +| anim-decl, 5k shapes, two derived values each | 24.6 | **32.3** | 11.6 | 9.4 | +| anim-imp, 5k shapes, one worklet | ~17 by hand | 54.9 | ~6 by hand | 21.9 | + +## CPU + +| scene | tgfx surface | skia surface | tgfx texture | skia texture | +|---|---|---|---|---| +| shapes | 189 % | 70 % | 202 % | 87 % | +| shapes-nodes | 184 % | 95 % | 200 % | 101 % | +| shapes-atlas | 48 % | 70 % | 76 % | 88 % | +| paths, 5,000 | 111 % | 53 % | 121 % | 53 % | +| paths, 10,000 | 167 % | 47 % | 204 % | 47 % | +| text | 128 % | 122 % | 146 % | 131 % | + +Whole process, 100 = one core. + +## Findings + +- **Shapes.** Each engine's fastest static path (`shapes`): skia's ShapeBlob + holds 89 fps; tgfx's 20k nodes reach 61 with `TgfxRender` saturated. With + the technique held equal the picture flips: 20k declarative nodes on + both, tgfx draws 2.2-2.4x skia (62 vs 26 surface); one atlas on both, + both sit at the ceiling and tgfx's `` mesh uses less CPU (48 vs + 70 %). +- **Paths.** skia is GPU-bound on this Mali at every count: 27 fps at 900 + and 2,500, 18 at 5,000, 10 at 10,000, with its render pool under 30 %. + tgfx holds 90 at 900 and 83 at 2,500, then `TgfxRender` saturates: 44 at + 5,000. At 10,000 it falls below skia, to 9 and 5, at 167 and 204 % CPU, + and the two runs disagree (9.7 and 8.2 surface, 10.7 and 4.3 texture): the + path geometry (about 86 MB) is larger than the canvas's GPU cache (64 MB), + so it is evicted and rebuilt every frame. +- **Text and recorded shapes.** tgfx leads by 2.2x and 2.7-3.2x; skia's + `RNSkia Render` is the limit on text (93 %). +- **Per-shape animation** is UI-thread bound for both (UI thread 96-98 %). + Declarative: skia ahead on SurfaceView, even on TextureView. tgfx + `anim-imp` is skipped by the runner; timed by hand inside the scene's + measured period (atrace, 8 s): about 17 fps surface, 6 texture. +- **SurfaceView vs TextureView.** Static rows lose up to 17 % on TextureView + for tgfx and up to 7 % for skia; `anim-decl` halves or worse on both. + +## Conditions + +- Thermal status 0-2 (2 for the whole TextureView half). The CPU cap was back + above 95 % at the start of every combo; tgfx's CPU-bound rows (shapes, + shapes-nodes, text, paths from 2,500 on TextureView) dipped to 68-80 % + mid-combo, so read differences under ~10 % there as noise. skia's GPU-bound + rows matched across reps and between the two builds to within 2 %. +- The notification shade was pulled down over the app for most of both + builds' runs (water on the screen while cooling it), so the runner's + parity stills show the shade. A back-to-back check with it closed and + open, eight combos each: skia's rows matched within 1 %; tgfx's + CPU-bound rows moved -5 to +8 %, in both directions, with the CPU cap. + Stills of the shapes scenes taken afterwards match across engines. diff --git a/apps/benchmark/bench/run.mjs b/apps/benchmark/bench/run.mjs index a6bf895..6542d3f 100644 --- a/apps/benchmark/bench/run.mjs +++ b/apps/benchmark/bench/run.mjs @@ -28,7 +28,7 @@ const PRESENT = arg('present', 'atrace'); // --gap idles the phone with no canvas between combos, so heat from one // engine's run is not carried into the next one's. const GAP = Number(arg('gap', '0')); -const ALL_SCENES = 'shapes,images,shader,pattern,paths,text,anim-decl,anim-imp,shapes-picture'; +const ALL_SCENES = 'shapes,shapes-nodes,shapes-atlas,images,shader,pattern,paths900,paths2500,paths5000,paths,text,anim-decl,anim-imp,shapes-picture'; // surface: both engines on a SurfaceView; texture: both on a TextureView. const VIEWS = arg('views', 'surface,texture'); // --skip tgfx:anim-imp drops engine:scene pairs (from every view).