From 293174e46bd93d0b946138df005a8242657b59d1 Mon Sep 17 00:00:00 2001 From: mickeypause Date: Mon, 2 Nov 2026 21:06:19 +0100 Subject: [PATCH 1/7] test(ios): reproduce offscreen memory growth --- CONTRIBUTING.md | 31 ++++++++++ apps/example/jest.harness.config.mjs | 1 + .../example/src/offscreenLeakSoak.harness.tsx | 62 +++++++++++++++++++ scripts/leak-check.mjs | 49 +++++++++++---- 4 files changed, 132 insertions(+), 11 deletions(-) create mode 100644 apps/example/src/offscreenLeakSoak.harness.tsx diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0d08984b..bf016439 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -131,6 +131,37 @@ it. It does not run in CI. `--runner ci-emu` runs it on the CI emulator instead of the phone, which catches allocation-path leaks (the registries, the scene, the JSI boundary) but not GPU-side growth. +### Offscreen memory reproduction (iOS Simulator) + +`src/offscreenLeakSoak.harness.tsx` uses one retained 512×512 surface for 450 +renders with fresh pixel uploads and one blur filter (temporary GPU targets). +Each `toImage()` waits for the offscreen +worker; both the input image and snapshot are disposed before the next +iteration. Pixel assertions at both ends verify the uploaded pixels and moving +rectangle actually rendered; the app reports no memory counters. + +Build and install the example first, then run from the repo root (replace the +simulator name, OS version and UDID with the same target): + +```sh +TGFX_IOS_SIMULATOR='iPhone 17 Pro' TGFX_IOS_VERSION='26.5' \ + node scripts/leak-check.mjs --ios-simulator --runner ios-sim \ + --metro-port 8094 --test src/offscreenLeakSoak.harness.tsx +``` + +The host samples that simulator's `TgfxExample` process with `ps`. The existing +warmup, median-growth threshold (30 MiB), and exit codes apply, but the metric is +RSS rather than Android PSS. A failed pixel test, missing process or insufficient +samples produces no passing memory verdict. Use fresh app launches on the same +simulator for before/after runs; rebuild after changing native code. Simulator +RSS demonstrates this regression, not physical-device or total GPU memory use. + +On Apple Silicon, the example's optional face detector can prevent simulator +builds because ML Kit excludes arm64 simulators. For this headless reproduction, +locally disable iOS autolinking of `react-native-vision-camera-face-detector` in +`apps/example/react-native.config.js`, then rerun `pod install`. The offscreen +test does not use the camera. + ## Imperative APIs first A lesson learned the hard way (see diff --git a/apps/example/jest.harness.config.mjs b/apps/example/jest.harness.config.mjs index 70b3316c..7320df1d 100644 --- a/apps/example/jest.harness.config.mjs +++ b/apps/example/jest.harness.config.mjs @@ -5,6 +5,7 @@ export default { // The ~90s memory soak is scripts/leak-check.mjs's business, not the // default suite's; the script re-enables it with --testPathIgnorePatterns='$^'. 'leakSoak', + 'offscreenLeakSoak', // The ~35s adb-watched purge scenario is scripts/cache-purge-check.mjs's // business, not the default suite's; the script re-enables it with // --testPathIgnorePatterns='$^'. diff --git a/apps/example/src/offscreenLeakSoak.harness.tsx b/apps/example/src/offscreenLeakSoak.harness.tsx new file mode 100644 index 00000000..524ea865 --- /dev/null +++ b/apps/example/src/offscreenLeakSoak.harness.tsx @@ -0,0 +1,62 @@ +// Run with scripts/leak-check.mjs; memory is measured outside the app. +import { describe, expect, test } from 'react-native-harness'; +import { + Scene, + blur, + createOffscreenSurface, + fill, + image, + imageFromPixels, + rect, +} from 'react-native-tgfx'; +import { sleep } from './testSupport'; + +describe('offscreen leak soak', () => { + test('repeatedly renders and releases snapshots on one retained surface', async () => { + const size = 512; + const surface = createOffscreenSurface({ width: size, height: size }); + const pixels = new Uint32Array(size * size); + const scene = Scene.create(); + try { + scene.attach(surface); + for (let frame = 0; frame < 450; frame += 1) { + const x = frame % 2 === 0 ? 0 : size - 32; + pixels.fill(0xff000000 + (frame % 256) * 0x10000); // opaque blue RGBA + const input = imageFromPixels(pixels.buffer, size, size); + try { + // Literal scenes isolate the worker from UI-runtime slot scheduling. + scene.replaceChildren([ + fill({ color: '#000' }), + image({ x: 0, y: 0, width: size, height: size, image: input }, [ + blur({ blur: 4 }), + ]), + rect({ x, y: 0, width: 32, height: 32, color: '#ff0000' }), + ]); + scene.flush(); + // Wait for a real worker render; flush coalescing cannot skip frames. + const snapshot = await surface.toImage(); + try { + if (frame < 2 || frame === 449) { + const bytes = new Uint8Array(await snapshot.encode('raw')); + expect(bytes.length).toBe(size * size * 4); + expect(bytes[(x + 16 * size) * 4]).toBe(255); + expect(bytes[(x + 16 * size) * 4 + 1]).toBe(0); + const background = (size / 2 + (size / 2) * size) * 4; + expect(bytes[background]).toBe(0); + expect(bytes[background + 2]).toBe(frame % 256); + } + } finally { + snapshot.dispose(); + } + } finally { + input.dispose(); + } + await sleep(150); + } + } finally { + scene.dispose(); + surface.dispose(); + } + await sleep(500); + }); +}); diff --git a/scripts/leak-check.mjs b/scripts/leak-check.mjs index 7c5c9c60..7fde83b9 100644 --- a/scripts/leak-check.mjs +++ b/scripts/leak-check.mjs @@ -1,12 +1,14 @@ #!/usr/bin/env node // Memory-leak gate: runs the leak soak (apps/example/src/leakSoak.harness.tsx) -// on the connected Android device while sampling `adb shell dumpsys meminfo` +// while sampling Android `adb shell dumpsys meminfo` or iOS Simulator `ps` // from the host. All measurement lives out here in OS accounting — the app // deliberately reports nothing about its own memory. // // node scripts/leak-check.mjs [--package com.tgfxexample] [--threshold-mb 30] // [--test src/leakSoak.harness.tsx] [--interval-ms 2000] // [--runner ci-emu] +// iOS Simulator: --ios-simulator --runner ios-sim --metro-port 8094 +// Select that same simulator with TGFX_IOS_SIMULATOR / TGFX_IOS_VERSION. // // Exit codes: 0 no leak, 1 leak detected, 2 the run itself failed. import { execFile, spawn } from 'node:child_process'; @@ -23,6 +25,9 @@ const PACKAGE = arg('package', 'com.tgfxexample'); const THRESHOLD_MB = Number(arg('threshold-mb', '30')); const TEST = arg('test', 'src/leakSoak.harness.tsx'); const INTERVAL_MS = Number(arg('interval-ms', '2000')); +const IOS_SIMULATOR = arg('ios-simulator', null); +const METRO_PORT = arg('metro-port', null); +const METRIC = IOS_SIMULATOR ? 'RSS' : 'TOTAL PSS'; const exampleDir = join(dirname(fileURLToPath(import.meta.url)), '..', 'apps', 'example'); @@ -57,14 +62,33 @@ let sampling = false; async function sample() { if (sampling) return; // a slow dumpsys must not stack behind the timer sampling = true; - const out = await adb('shell', 'dumpsys', 'meminfo', PACKAGE); + const out = IOS_SIMULATOR + ? await new Promise(resolve => { + execFile( + 'ps', ['-axo', 'rss=,command='], { maxBuffer: 4 * 1024 * 1024 }, + (error, stdout) => resolve(error ? null : stdout) + ); + }) + : await adb('shell', 'dumpsys', 'meminfo', PACKAGE); sampling = false; - const parsed = out && parseMeminfo(out); - if (!parsed) return; + // Match this clone's executable path, never another booted simulator's app. + let parsed = null; + if (IOS_SIMULATOR) { + const rows = out?.split('\n').filter(row => + row.includes(`/Devices/${IOS_SIMULATOR}/`) && + row.includes('/TgfxExample.app/TgfxExample') + ); + if (rows?.length === 1) parsed = { total: Number.parseInt(rows[0], 10) }; + } else { + parsed = out && parseMeminfo(out); + } + if (!parsed || !Number.isFinite(parsed.total)) return; samples.push(parsed); console.log( - `[leak-check] #${samples.length} total ${mb(parsed.total)}MB ` + - `native ${mb(parsed.native ?? 0)}MB graphics ${mb(parsed.graphics ?? 0)}MB` + `[leak-check] #${samples.length} ${METRIC} ${mb(parsed.total)}MB` + + (IOS_SIMULATOR + ? '' + : ` native ${mb(parsed.native ?? 0)}MB graphics ${mb(parsed.graphics ?? 0)}MB`) ); } @@ -84,11 +108,13 @@ function verdict() { console.log( `[leak-check] settled growth (median of last third vs first third, ${settled.length} samples):` ); - console.log(`[leak-check] TOTAL PSS ${mb(totalGrowth)}MB (threshold ${THRESHOLD_MB}MB)`); - console.log(`[leak-check] Native Heap ${mb(growth('native'))}MB`); - console.log(`[leak-check] Graphics ${mb(growth('graphics'))}MB`); + console.log(`[leak-check] ${METRIC} ${mb(totalGrowth)}MB (threshold ${THRESHOLD_MB}MB)`); + if (!IOS_SIMULATOR) { + console.log(`[leak-check] Native Heap ${mb(growth('native'))}MB`); + console.log(`[leak-check] Graphics ${mb(growth('graphics'))}MB`); + } if (totalGrowth > THRESHOLD_MB * 1024) { - console.error(`::error::memory leak: TOTAL PSS grew ${mb(totalGrowth)}MB during the soak`); + console.error(`::error::memory leak: ${METRIC} grew ${mb(totalGrowth)}MB during the soak`); return 1; } console.log('[leak-check] OK — no leak detected'); @@ -96,7 +122,7 @@ function verdict() { } // A leftover instance would poison the early samples with its own memory. -await adb('shell', 'am', 'force-stop', PACKAGE); +if (!IOS_SIMULATOR) await adb('shell', 'am', 'force-stop', PACKAGE); const runner = arg('runner', null); const child = spawn( @@ -108,6 +134,7 @@ const child = spawn( TEST, '--testPathIgnorePatterns=$^', ...(runner ? [`--harnessRunner=${runner}`] : []), + ...(METRO_PORT ? [`--metroPort=${METRO_PORT}`] : []), ], { cwd: exampleDir, stdio: 'inherit' } ); From 0b21abad018be9f55cbbbd900ca00a4f5f48bbe6 Mon Sep 17 00:00:00 2001 From: mickeypause Date: Mon, 2 Nov 2026 21:10:32 +0100 Subject: [PATCH 2/7] fix(ios): drain offscreen autorelease pools Bound Metal temporaries to each worker drain, including final surface cleanup. Keep the Android C++ path unchanged. 450 filtered renders: RSS growth +51.6 MiB before, -3.7 MiB after (30 MiB gate; Debug iOS Simulator). --- .../cpp/Offscreen/OffscreenSurface.cpp | 8 ++++++++ .../react-native-tgfx/cpp/tests/CMakeLists.txt | 6 ++++++ .../ios/TgfxOffscreenSurface.mm | 16 ++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 packages/react-native-tgfx/ios/TgfxOffscreenSurface.mm diff --git a/packages/react-native-tgfx/cpp/Offscreen/OffscreenSurface.cpp b/packages/react-native-tgfx/cpp/Offscreen/OffscreenSurface.cpp index 38bbf1bd..ed58c2ef 100644 --- a/packages/react-native-tgfx/cpp/Offscreen/OffscreenSurface.cpp +++ b/packages/react-native-tgfx/cpp/Offscreen/OffscreenSurface.cpp @@ -21,6 +21,10 @@ namespace tgfxrn { +#if defined(__APPLE__) +void renderOffscreenAutoreleased(const std::weak_ptr& next); +#endif + namespace { /** @@ -60,9 +64,13 @@ class OffscreenWorker { next = std::move(queue_.front()); queue_.pop_front(); } +#if defined(__APPLE__) + renderOffscreenAutoreleased(next); +#else if (auto surface = next.lock()) { surface->renderNow(); } +#endif } } diff --git a/packages/react-native-tgfx/cpp/tests/CMakeLists.txt b/packages/react-native-tgfx/cpp/tests/CMakeLists.txt index 2d9090a6..b25e6fe7 100644 --- a/packages/react-native-tgfx/cpp/tests/CMakeLists.txt +++ b/packages/react-native-tgfx/cpp/tests/CMakeLists.txt @@ -14,6 +14,12 @@ add_subdirectory(${TGFX_DIR} ${CMAKE_BINARY_DIR}/tgfx) add_executable(SceneTest SceneTest.cpp ../Scene/TgfxScene.cpp ../Path/SvgPath.cpp ../Image/SvgImage.cpp ../Image/ImageRegistry.cpp ../Offscreen/OffscreenRender.cpp ../Offscreen/OffscreenSurface.cpp ../Export/PdfExport.cpp ../Export/SvgExport.cpp ../TextLayout/FontRegistry.cpp ../TextLayout/TextLayout.cpp ../TextLayout/TextShaping.cpp ../Path/PathOps.cpp ../Buffers/BufferRegistry.cpp) +if(APPLE) + enable_language(OBJCXX) + set_property(TARGET SceneTest PROPERTY OBJCXX_STANDARD 20) + target_sources(SceneTest PRIVATE ../../ios/TgfxOffscreenSurface.mm) + target_link_libraries(SceneTest "-framework Foundation") +endif() # tgfx's src too: the EXIF test names JpegCodec rather than going through # ImageCodec::MakeFrom, which would fall through to the platform decoder and # prove nothing about the embedded one. diff --git a/packages/react-native-tgfx/ios/TgfxOffscreenSurface.mm b/packages/react-native-tgfx/ios/TgfxOffscreenSurface.mm new file mode 100644 index 00000000..bd73e8aa --- /dev/null +++ b/packages/react-native-tgfx/ios/TgfxOffscreenSurface.mm @@ -0,0 +1,16 @@ +#import + +#include "OffscreenSurface.hpp" + +namespace tgfxrn { + +void renderOffscreenAutoreleased(const std::weak_ptr& next) { + // Detached C++ threads do not drain autoreleased Metal objects themselves. + @autoreleasepool { + if (auto surface = next.lock()) { + surface->renderNow(); + } + } +} + +} // namespace tgfxrn From ed91edfc6909853b2d2b8214b71b0c04c7e61915 Mon Sep 17 00:00:00 2001 From: mickeypause Date: Mon, 2 Nov 2026 21:41:46 +0100 Subject: [PATCH 3/7] test: harden offscreen memory regression checks Discard earlier-process RSS samples after Harness restarts the app. Assert blur blends an interior boundary; reject a zero-blur control. Add regression checks for process changes and insufficient samples. --- CONTRIBUTING.md | 13 +++- .../example/src/offscreenLeakSoak.harness.tsx | 13 +++- scripts/leak-check.mjs | 75 +++++++++++-------- scripts/leak-check.test.mjs | 26 +++++++ 4 files changed, 90 insertions(+), 37 deletions(-) create mode 100644 scripts/leak-check.test.mjs diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bf016439..a0ef0e22 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -137,8 +137,9 @@ scene, the JSI boundary) but not GPU-side growth. renders with fresh pixel uploads and one blur filter (temporary GPU targets). Each `toImage()` waits for the offscreen worker; both the input image and snapshot are disposed before the next -iteration. Pixel assertions at both ends verify the uploaded pixels and moving -rectangle actually rendered; the app reports no memory counters. +iteration. Pixel assertions verify the uploaded pixels, moving rectangle, and +blending across a sharp interior boundary, so bypassing blur fails the test. +The app reports no memory counters. Build and install the example first, then run from the repo root (replace the simulator name, OS version and UDID with the same target): @@ -151,11 +152,15 @@ TGFX_IOS_SIMULATOR='iPhone 17 Pro' TGFX_IOS_VERSION='26.5' \ The host samples that simulator's `TgfxExample` process with `ps`. The existing warmup, median-growth threshold (30 MiB), and exit codes apply, but the metric is -RSS rather than Android PSS. A failed pixel test, missing process or insufficient -samples produces no passing memory verdict. Use fresh app launches on the same +RSS rather than Android PSS. A changed process ID discards the earlier process's +samples and starts warmup again. A failed pixel test, missing process or +insufficient samples produces no passing memory verdict. Use fresh app launches on the same simulator for before/after runs; rebuild after changing native code. Simulator RSS demonstrates this regression, not physical-device or total GPU memory use. +`node --test scripts/leak-check.test.mjs` checks process restarts, insufficient +samples after a restart, and a stable process without launching a device. + On Apple Silicon, the example's optional face detector can prevent simulator builds because ML Kit excludes arm64 simulators. For this headless reproduction, locally disable iOS autolinking of `react-native-vision-camera-face-detector` in diff --git a/apps/example/src/offscreenLeakSoak.harness.tsx b/apps/example/src/offscreenLeakSoak.harness.tsx index 524ea865..6d697441 100644 --- a/apps/example/src/offscreenLeakSoak.harness.tsx +++ b/apps/example/src/offscreenLeakSoak.harness.tsx @@ -21,7 +21,10 @@ describe('offscreen leak soak', () => { scene.attach(surface); for (let frame = 0; frame < 450; frame += 1) { const x = frame % 2 === 0 ? 0 : size - 32; - pixels.fill(0xff000000 + (frame % 256) * 0x10000); // opaque blue RGBA + const blue = frame % 256; + const top = 0xff000000 + blue * 0x10000; + pixels.fill(top); + pixels.fill(top + 0xffff, pixels.length / 2); // sharp horizontal boundary const input = imageFromPixels(pixels.buffer, size, size); try { // Literal scenes isolate the worker from UI-runtime slot scheduling. @@ -41,9 +44,13 @@ describe('offscreen leak soak', () => { expect(bytes.length).toBe(size * size * 4); expect(bytes[(x + 16 * size) * 4]).toBe(255); expect(bytes[(x + 16 * size) * 4 + 1]).toBe(0); - const background = (size / 2 + (size / 2) * size) * 4; + const background = (size / 2 + (size / 4) * size) * 4; expect(bytes[background]).toBe(0); - expect(bytes[background + 2]).toBe(frame % 256); + expect(bytes[background + 2]).toBe(blue); + const boundary = (size / 2 + (size / 2) * size) * 4; + // Without blur this first pixel in the bottom half is 255. + expect(bytes[boundary]).toBeGreaterThan(32); + expect(bytes[boundary]).toBeLessThan(223); } } finally { snapshot.dispose(); diff --git a/scripts/leak-check.mjs b/scripts/leak-check.mjs index 7fde83b9..c98cc800 100644 --- a/scripts/leak-check.mjs +++ b/scripts/leak-check.mjs @@ -12,7 +12,7 @@ // // Exit codes: 0 no leak, 1 leak detected, 2 the run itself failed. import { execFile, spawn } from 'node:child_process'; -import { dirname, join } from 'node:path'; +import { dirname, join, resolve } from 'node:path'; import { fileURLToPath } from 'node:url'; const args = process.argv.slice(2); @@ -58,6 +58,15 @@ const median = values => { const mb = kb => (kb / 1024).toFixed(1); const samples = []; +let sampledPid = null; +export function recordSample(parsed) { + if (parsed.pid !== undefined && parsed.pid !== sampledPid) { + // Harness may restart an existing app; never compare across processes. + samples.length = 0; + sampledPid = parsed.pid; + } + samples.push(parsed); +} let sampling = false; async function sample() { if (sampling) return; // a slow dumpsys must not stack behind the timer @@ -65,7 +74,7 @@ async function sample() { const out = IOS_SIMULATOR ? await new Promise(resolve => { execFile( - 'ps', ['-axo', 'rss=,command='], { maxBuffer: 4 * 1024 * 1024 }, + 'ps', ['-axo', 'pid=,rss=,command='], { maxBuffer: 4 * 1024 * 1024 }, (error, stdout) => resolve(error ? null : stdout) ); }) @@ -78,21 +87,25 @@ async function sample() { row.includes(`/Devices/${IOS_SIMULATOR}/`) && row.includes('/TgfxExample.app/TgfxExample') ); - if (rows?.length === 1) parsed = { total: Number.parseInt(rows[0], 10) }; + if (rows?.length === 1) { + const [pid, total] = rows[0].trim().split(/\s+/, 2).map(Number); + if (Number.isInteger(pid) && pid > 0) parsed = { pid, total }; + } } else { parsed = out && parseMeminfo(out); } if (!parsed || !Number.isFinite(parsed.total)) return; - samples.push(parsed); + recordSample(parsed); console.log( `[leak-check] #${samples.length} ${METRIC} ${mb(parsed.total)}MB` + + (IOS_SIMULATOR ? ` pid=${parsed.pid}` : '') + (IOS_SIMULATOR ? '' : ` native ${mb(parsed.native ?? 0)}MB graphics ${mb(parsed.graphics ?? 0)}MB`) ); } -function verdict() { +export function verdict() { // The first samples straddle install/launch/first-frames; judge steady state. const warmup = Math.max(5, Math.ceil(samples.length * 0.25)); const settled = samples.slice(warmup); @@ -121,29 +134,31 @@ function verdict() { return 0; } -// A leftover instance would poison the early samples with its own memory. -if (!IOS_SIMULATOR) await adb('shell', 'am', 'force-stop', PACKAGE); +if (process.argv[1] && fileURLToPath(import.meta.url) === resolve(process.argv[1])) { + // A leftover instance would poison the early samples with its own memory. + if (!IOS_SIMULATOR) await adb('shell', 'am', 'force-stop', PACKAGE); -const runner = arg('runner', null); -const child = spawn( - 'bun', - [ - 'harness', - // The test path must come before the ignore override: yargs array options - // greedily swallow every following positional, `=` form included. - TEST, - '--testPathIgnorePatterns=$^', - ...(runner ? [`--harnessRunner=${runner}`] : []), - ...(METRO_PORT ? [`--metroPort=${METRO_PORT}`] : []), - ], - { cwd: exampleDir, stdio: 'inherit' } -); -const timer = setInterval(sample, INTERVAL_MS); -child.on('exit', code => { - clearInterval(timer); - if (code !== 0) { - console.error(`[leak-check] harness exited with ${code} — no verdict`); - process.exit(2); - } - process.exit(verdict()); -}); + const runner = arg('runner', null); + const child = spawn( + 'bun', + [ + 'harness', + // The test path must come before the ignore override: yargs array options + // greedily swallow every following positional, `=` form included. + TEST, + '--testPathIgnorePatterns=$^', + ...(runner ? [`--harnessRunner=${runner}`] : []), + ...(METRO_PORT ? [`--metroPort=${METRO_PORT}`] : []), + ], + { cwd: exampleDir, stdio: 'inherit' } + ); + const timer = setInterval(sample, INTERVAL_MS); + child.on('exit', code => { + clearInterval(timer); + if (code !== 0) { + console.error(`[leak-check] harness exited with ${code} — no verdict`); + process.exit(2); + } + process.exit(verdict()); + }); +} diff --git a/scripts/leak-check.test.mjs b/scripts/leak-check.test.mjs new file mode 100644 index 00000000..bd1d5c47 --- /dev/null +++ b/scripts/leak-check.test.mjs @@ -0,0 +1,26 @@ +import assert from 'node:assert/strict'; +import test from 'node:test'; +import { recordSample, verdict } from './leak-check.mjs'; + +function trace(pid, count, startMiB, growthMiB = 0) { + for (let i = 0; i < count; i++) { + recordSample({ pid, total: (startMiB + i * growthMiB) * 1024 }); + } +} + +test('an older large process cannot hide growth in the restarted app', () => { + trace(101, 30, 900); // 60 seconds of preparation at a two-second interval. + trace(102, 40, 200, 2); + assert.equal(verdict(), 1); +}); + +test('a new process must supply enough of its own settled samples', () => { + trace(201, 40, 250); + trace(202, 10, 250); + assert.equal(verdict(), 2); +}); + +test('a stable process with enough samples passes', () => { + trace(301, 40, 250); + assert.equal(verdict(), 0); +}); From 3313b99d98eb9028477b01d2555aea1c8633f9b0 Mon Sep 17 00:00:00 2001 From: mickeypause Date: Mon, 2 Nov 2026 22:11:35 +0100 Subject: [PATCH 4/7] chore: narrow offscreen fix PR scope Restore contributor docs, runner configuration, and Android leak tooling. Preserve iOS measurement tools on validation/ios-offscreen-memory. Keep the offscreen workload and its combined Jest exclusion list. --- CONTRIBUTING.md | 36 ------ .../example/src/offscreenLeakSoak.harness.tsx | 2 +- scripts/leak-check.mjs | 116 ++++++------------ scripts/leak-check.test.mjs | 26 ---- 4 files changed, 38 insertions(+), 142 deletions(-) delete mode 100644 scripts/leak-check.test.mjs diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a0ef0e22..0d08984b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -131,42 +131,6 @@ it. It does not run in CI. `--runner ci-emu` runs it on the CI emulator instead of the phone, which catches allocation-path leaks (the registries, the scene, the JSI boundary) but not GPU-side growth. -### Offscreen memory reproduction (iOS Simulator) - -`src/offscreenLeakSoak.harness.tsx` uses one retained 512×512 surface for 450 -renders with fresh pixel uploads and one blur filter (temporary GPU targets). -Each `toImage()` waits for the offscreen -worker; both the input image and snapshot are disposed before the next -iteration. Pixel assertions verify the uploaded pixels, moving rectangle, and -blending across a sharp interior boundary, so bypassing blur fails the test. -The app reports no memory counters. - -Build and install the example first, then run from the repo root (replace the -simulator name, OS version and UDID with the same target): - -```sh -TGFX_IOS_SIMULATOR='iPhone 17 Pro' TGFX_IOS_VERSION='26.5' \ - node scripts/leak-check.mjs --ios-simulator --runner ios-sim \ - --metro-port 8094 --test src/offscreenLeakSoak.harness.tsx -``` - -The host samples that simulator's `TgfxExample` process with `ps`. The existing -warmup, median-growth threshold (30 MiB), and exit codes apply, but the metric is -RSS rather than Android PSS. A changed process ID discards the earlier process's -samples and starts warmup again. A failed pixel test, missing process or -insufficient samples produces no passing memory verdict. Use fresh app launches on the same -simulator for before/after runs; rebuild after changing native code. Simulator -RSS demonstrates this regression, not physical-device or total GPU memory use. - -`node --test scripts/leak-check.test.mjs` checks process restarts, insufficient -samples after a restart, and a stable process without launching a device. - -On Apple Silicon, the example's optional face detector can prevent simulator -builds because ML Kit excludes arm64 simulators. For this headless reproduction, -locally disable iOS autolinking of `react-native-vision-camera-face-detector` in -`apps/example/react-native.config.js`, then rerun `pod install`. The offscreen -test does not use the camera. - ## Imperative APIs first A lesson learned the hard way (see diff --git a/apps/example/src/offscreenLeakSoak.harness.tsx b/apps/example/src/offscreenLeakSoak.harness.tsx index 6d697441..f223b3cc 100644 --- a/apps/example/src/offscreenLeakSoak.harness.tsx +++ b/apps/example/src/offscreenLeakSoak.harness.tsx @@ -1,4 +1,4 @@ -// Run with scripts/leak-check.mjs; memory is measured outside the app. +// Pixel assertions verify the workload; memory is measured outside the app. import { describe, expect, test } from 'react-native-harness'; import { Scene, diff --git a/scripts/leak-check.mjs b/scripts/leak-check.mjs index c98cc800..7c5c9c60 100644 --- a/scripts/leak-check.mjs +++ b/scripts/leak-check.mjs @@ -1,18 +1,16 @@ #!/usr/bin/env node // Memory-leak gate: runs the leak soak (apps/example/src/leakSoak.harness.tsx) -// while sampling Android `adb shell dumpsys meminfo` or iOS Simulator `ps` +// on the connected Android device while sampling `adb shell dumpsys meminfo` // from the host. All measurement lives out here in OS accounting — the app // deliberately reports nothing about its own memory. // // node scripts/leak-check.mjs [--package com.tgfxexample] [--threshold-mb 30] // [--test src/leakSoak.harness.tsx] [--interval-ms 2000] // [--runner ci-emu] -// iOS Simulator: --ios-simulator --runner ios-sim --metro-port 8094 -// Select that same simulator with TGFX_IOS_SIMULATOR / TGFX_IOS_VERSION. // // Exit codes: 0 no leak, 1 leak detected, 2 the run itself failed. import { execFile, spawn } from 'node:child_process'; -import { dirname, join, resolve } from 'node:path'; +import { dirname, join } from 'node:path'; import { fileURLToPath } from 'node:url'; const args = process.argv.slice(2); @@ -25,9 +23,6 @@ const PACKAGE = arg('package', 'com.tgfxexample'); const THRESHOLD_MB = Number(arg('threshold-mb', '30')); const TEST = arg('test', 'src/leakSoak.harness.tsx'); const INTERVAL_MS = Number(arg('interval-ms', '2000')); -const IOS_SIMULATOR = arg('ios-simulator', null); -const METRO_PORT = arg('metro-port', null); -const METRIC = IOS_SIMULATOR ? 'RSS' : 'TOTAL PSS'; const exampleDir = join(dirname(fileURLToPath(import.meta.url)), '..', 'apps', 'example'); @@ -58,54 +53,22 @@ const median = values => { const mb = kb => (kb / 1024).toFixed(1); const samples = []; -let sampledPid = null; -export function recordSample(parsed) { - if (parsed.pid !== undefined && parsed.pid !== sampledPid) { - // Harness may restart an existing app; never compare across processes. - samples.length = 0; - sampledPid = parsed.pid; - } - samples.push(parsed); -} let sampling = false; async function sample() { if (sampling) return; // a slow dumpsys must not stack behind the timer sampling = true; - const out = IOS_SIMULATOR - ? await new Promise(resolve => { - execFile( - 'ps', ['-axo', 'pid=,rss=,command='], { maxBuffer: 4 * 1024 * 1024 }, - (error, stdout) => resolve(error ? null : stdout) - ); - }) - : await adb('shell', 'dumpsys', 'meminfo', PACKAGE); + const out = await adb('shell', 'dumpsys', 'meminfo', PACKAGE); sampling = false; - // Match this clone's executable path, never another booted simulator's app. - let parsed = null; - if (IOS_SIMULATOR) { - const rows = out?.split('\n').filter(row => - row.includes(`/Devices/${IOS_SIMULATOR}/`) && - row.includes('/TgfxExample.app/TgfxExample') - ); - if (rows?.length === 1) { - const [pid, total] = rows[0].trim().split(/\s+/, 2).map(Number); - if (Number.isInteger(pid) && pid > 0) parsed = { pid, total }; - } - } else { - parsed = out && parseMeminfo(out); - } - if (!parsed || !Number.isFinite(parsed.total)) return; - recordSample(parsed); + const parsed = out && parseMeminfo(out); + if (!parsed) return; + samples.push(parsed); console.log( - `[leak-check] #${samples.length} ${METRIC} ${mb(parsed.total)}MB` + - (IOS_SIMULATOR ? ` pid=${parsed.pid}` : '') + - (IOS_SIMULATOR - ? '' - : ` native ${mb(parsed.native ?? 0)}MB graphics ${mb(parsed.graphics ?? 0)}MB`) + `[leak-check] #${samples.length} total ${mb(parsed.total)}MB ` + + `native ${mb(parsed.native ?? 0)}MB graphics ${mb(parsed.graphics ?? 0)}MB` ); } -export function verdict() { +function verdict() { // The first samples straddle install/launch/first-frames; judge steady state. const warmup = Math.max(5, Math.ceil(samples.length * 0.25)); const settled = samples.slice(warmup); @@ -121,44 +84,39 @@ export function verdict() { console.log( `[leak-check] settled growth (median of last third vs first third, ${settled.length} samples):` ); - console.log(`[leak-check] ${METRIC} ${mb(totalGrowth)}MB (threshold ${THRESHOLD_MB}MB)`); - if (!IOS_SIMULATOR) { - console.log(`[leak-check] Native Heap ${mb(growth('native'))}MB`); - console.log(`[leak-check] Graphics ${mb(growth('graphics'))}MB`); - } + console.log(`[leak-check] TOTAL PSS ${mb(totalGrowth)}MB (threshold ${THRESHOLD_MB}MB)`); + console.log(`[leak-check] Native Heap ${mb(growth('native'))}MB`); + console.log(`[leak-check] Graphics ${mb(growth('graphics'))}MB`); if (totalGrowth > THRESHOLD_MB * 1024) { - console.error(`::error::memory leak: ${METRIC} grew ${mb(totalGrowth)}MB during the soak`); + console.error(`::error::memory leak: TOTAL PSS grew ${mb(totalGrowth)}MB during the soak`); return 1; } console.log('[leak-check] OK — no leak detected'); return 0; } -if (process.argv[1] && fileURLToPath(import.meta.url) === resolve(process.argv[1])) { - // A leftover instance would poison the early samples with its own memory. - if (!IOS_SIMULATOR) await adb('shell', 'am', 'force-stop', PACKAGE); +// A leftover instance would poison the early samples with its own memory. +await adb('shell', 'am', 'force-stop', PACKAGE); - const runner = arg('runner', null); - const child = spawn( - 'bun', - [ - 'harness', - // The test path must come before the ignore override: yargs array options - // greedily swallow every following positional, `=` form included. - TEST, - '--testPathIgnorePatterns=$^', - ...(runner ? [`--harnessRunner=${runner}`] : []), - ...(METRO_PORT ? [`--metroPort=${METRO_PORT}`] : []), - ], - { cwd: exampleDir, stdio: 'inherit' } - ); - const timer = setInterval(sample, INTERVAL_MS); - child.on('exit', code => { - clearInterval(timer); - if (code !== 0) { - console.error(`[leak-check] harness exited with ${code} — no verdict`); - process.exit(2); - } - process.exit(verdict()); - }); -} +const runner = arg('runner', null); +const child = spawn( + 'bun', + [ + 'harness', + // The test path must come before the ignore override: yargs array options + // greedily swallow every following positional, `=` form included. + TEST, + '--testPathIgnorePatterns=$^', + ...(runner ? [`--harnessRunner=${runner}`] : []), + ], + { cwd: exampleDir, stdio: 'inherit' } +); +const timer = setInterval(sample, INTERVAL_MS); +child.on('exit', code => { + clearInterval(timer); + if (code !== 0) { + console.error(`[leak-check] harness exited with ${code} — no verdict`); + process.exit(2); + } + process.exit(verdict()); +}); diff --git a/scripts/leak-check.test.mjs b/scripts/leak-check.test.mjs deleted file mode 100644 index bd1d5c47..00000000 --- a/scripts/leak-check.test.mjs +++ /dev/null @@ -1,26 +0,0 @@ -import assert from 'node:assert/strict'; -import test from 'node:test'; -import { recordSample, verdict } from './leak-check.mjs'; - -function trace(pid, count, startMiB, growthMiB = 0) { - for (let i = 0; i < count; i++) { - recordSample({ pid, total: (startMiB + i * growthMiB) * 1024 }); - } -} - -test('an older large process cannot hide growth in the restarted app', () => { - trace(101, 30, 900); // 60 seconds of preparation at a two-second interval. - trace(102, 40, 200, 2); - assert.equal(verdict(), 1); -}); - -test('a new process must supply enough of its own settled samples', () => { - trace(201, 40, 250); - trace(202, 10, 250); - assert.equal(verdict(), 2); -}); - -test('a stable process with enough samples passes', () => { - trace(301, 40, 250); - assert.equal(verdict(), 0); -}); From 642d0a52199def72f107791659a1ceb50d9ccfa6 Mon Sep 17 00:00:00 2001 From: mickeypause Date: Tue, 3 Nov 2026 19:06:04 +0100 Subject: [PATCH 5/7] test: consolidate offscreen leak harness --- apps/example/jest.harness.config.mjs | 1 - apps/example/src/offscreen.harness.tsx | 59 ++++++++++++++++ .../example/src/offscreenLeakSoak.harness.tsx | 69 ------------------- 3 files changed, 59 insertions(+), 70 deletions(-) delete mode 100644 apps/example/src/offscreenLeakSoak.harness.tsx diff --git a/apps/example/jest.harness.config.mjs b/apps/example/jest.harness.config.mjs index 7320df1d..70b3316c 100644 --- a/apps/example/jest.harness.config.mjs +++ b/apps/example/jest.harness.config.mjs @@ -5,7 +5,6 @@ export default { // The ~90s memory soak is scripts/leak-check.mjs's business, not the // default suite's; the script re-enables it with --testPathIgnorePatterns='$^'. 'leakSoak', - 'offscreenLeakSoak', // The ~35s adb-watched purge scenario is scripts/cache-purge-check.mjs's // business, not the default suite's; the script re-enables it with // --testPathIgnorePatterns='$^'. diff --git a/apps/example/src/offscreen.harness.tsx b/apps/example/src/offscreen.harness.tsx index 6cab45c4..86546e84 100644 --- a/apps/example/src/offscreen.harness.tsx +++ b/apps/example/src/offscreen.harness.tsx @@ -10,11 +10,14 @@ import { Rect, RoundedRect, Scene, + blur, circle, createHandle, createOffscreenSurface, fill, group, + image, + imageFromPixels, rect, renderToImage, rrect, @@ -168,4 +171,60 @@ describe('tgfx offscreen surface', () => { } expect(failed).toBe(true); }); + + // Pixel assertions verify the workload; memory is measured outside the app. + test('offscreen leak soak: repeatedly renders and releases snapshots on one retained surface', async () => { + const size = 512; + const surface = createOffscreenSurface({ width: size, height: size }); + const pixels = new Uint32Array(size * size); + const scene = Scene.create(); + try { + scene.attach(surface); + for (let frame = 0; frame < 450; frame += 1) { + const x = frame % 2 === 0 ? 0 : size - 32; + const blue = frame % 256; + const top = 0xff000000 + blue * 0x10000; + pixels.fill(top); + pixels.fill(top + 0xffff, pixels.length / 2); // sharp horizontal boundary + const input = imageFromPixels(pixels.buffer, size, size); + try { + // Literal scenes isolate the worker from UI-runtime slot scheduling. + scene.replaceChildren([ + fill({ color: '#000' }), + image({ x: 0, y: 0, width: size, height: size, image: input }, [ + blur({ blur: 4 }), + ]), + rect({ x, y: 0, width: 32, height: 32, color: '#ff0000' }), + ]); + scene.flush(); + // Wait for a real worker render; flush coalescing cannot skip frames. + const snapshot = await surface.toImage(); + try { + if (frame < 2 || frame === 449) { + const bytes = new Uint8Array(await snapshot.encode('raw')); + expect(bytes.length).toBe(size * size * 4); + expect(bytes[(x + 16 * size) * 4]).toBe(255); + expect(bytes[(x + 16 * size) * 4 + 1]).toBe(0); + const background = (size / 2 + (size / 4) * size) * 4; + expect(bytes[background]).toBe(0); + expect(bytes[background + 2]).toBe(blue); + const boundary = (size / 2 + (size / 2) * size) * 4; + // Without blur this first pixel in the bottom half is 255. + expect(bytes[boundary]).toBeGreaterThan(32); + expect(bytes[boundary]).toBeLessThan(223); + } + } finally { + snapshot.dispose(); + } + } finally { + input.dispose(); + } + await sleep(150); + } + } finally { + scene.dispose(); + surface.dispose(); + } + await sleep(500); + }); }); diff --git a/apps/example/src/offscreenLeakSoak.harness.tsx b/apps/example/src/offscreenLeakSoak.harness.tsx deleted file mode 100644 index f223b3cc..00000000 --- a/apps/example/src/offscreenLeakSoak.harness.tsx +++ /dev/null @@ -1,69 +0,0 @@ -// Pixel assertions verify the workload; memory is measured outside the app. -import { describe, expect, test } from 'react-native-harness'; -import { - Scene, - blur, - createOffscreenSurface, - fill, - image, - imageFromPixels, - rect, -} from 'react-native-tgfx'; -import { sleep } from './testSupport'; - -describe('offscreen leak soak', () => { - test('repeatedly renders and releases snapshots on one retained surface', async () => { - const size = 512; - const surface = createOffscreenSurface({ width: size, height: size }); - const pixels = new Uint32Array(size * size); - const scene = Scene.create(); - try { - scene.attach(surface); - for (let frame = 0; frame < 450; frame += 1) { - const x = frame % 2 === 0 ? 0 : size - 32; - const blue = frame % 256; - const top = 0xff000000 + blue * 0x10000; - pixels.fill(top); - pixels.fill(top + 0xffff, pixels.length / 2); // sharp horizontal boundary - const input = imageFromPixels(pixels.buffer, size, size); - try { - // Literal scenes isolate the worker from UI-runtime slot scheduling. - scene.replaceChildren([ - fill({ color: '#000' }), - image({ x: 0, y: 0, width: size, height: size, image: input }, [ - blur({ blur: 4 }), - ]), - rect({ x, y: 0, width: 32, height: 32, color: '#ff0000' }), - ]); - scene.flush(); - // Wait for a real worker render; flush coalescing cannot skip frames. - const snapshot = await surface.toImage(); - try { - if (frame < 2 || frame === 449) { - const bytes = new Uint8Array(await snapshot.encode('raw')); - expect(bytes.length).toBe(size * size * 4); - expect(bytes[(x + 16 * size) * 4]).toBe(255); - expect(bytes[(x + 16 * size) * 4 + 1]).toBe(0); - const background = (size / 2 + (size / 4) * size) * 4; - expect(bytes[background]).toBe(0); - expect(bytes[background + 2]).toBe(blue); - const boundary = (size / 2 + (size / 2) * size) * 4; - // Without blur this first pixel in the bottom half is 255. - expect(bytes[boundary]).toBeGreaterThan(32); - expect(bytes[boundary]).toBeLessThan(223); - } - } finally { - snapshot.dispose(); - } - } finally { - input.dispose(); - } - await sleep(150); - } - } finally { - scene.dispose(); - surface.dispose(); - } - await sleep(500); - }); -}); From 483262ecf2da7568538a9c3661fdfd1b985939fc Mon Sep 17 00:00:00 2001 From: riteshshukla04 Date: Wed, 4 Nov 2026 01:12:57 +0530 Subject: [PATCH 6/7] fix(ios): drain autorelease pools for all offscreen GPU work Hold the pool in OffscreenContext instead of around the worker loop. renderToImage, encode and save take the offscreen device on Nitro's promise threads, which never drain a pool either. Every offscreen GPU call already runs inside an OffscreenContext, so one RAII member covers the worker, those calls and surface teardown. 450 iterations on the iOS 27 simulator: - offscreen leak soak: +2.5 MiB - renderToImage: +2.6 MiB (was +83.5 MiB) - encode('png'): flat (was +50.9 MiB) --- .../cpp/Offscreen/OffscreenRender.hpp | 24 +++++++++++++++++++ .../cpp/Offscreen/OffscreenSurface.cpp | 8 ------- .../cpp/tests/CMakeLists.txt | 2 +- .../ios/TgfxAutoreleasePool.mm | 16 +++++++++++++ .../ios/TgfxOffscreenSurface.mm | 16 ------------- 5 files changed, 41 insertions(+), 25 deletions(-) create mode 100644 packages/react-native-tgfx/ios/TgfxAutoreleasePool.mm delete mode 100644 packages/react-native-tgfx/ios/TgfxOffscreenSurface.mm diff --git a/packages/react-native-tgfx/cpp/Offscreen/OffscreenRender.hpp b/packages/react-native-tgfx/cpp/Offscreen/OffscreenRender.hpp index 9bf88d14..68480166 100644 --- a/packages/react-native-tgfx/cpp/Offscreen/OffscreenRender.hpp +++ b/packages/react-native-tgfx/cpp/Offscreen/OffscreenRender.hpp @@ -19,6 +19,28 @@ class Image; namespace tgfxrn { +/** + * Drains what Metal autoreleases inside its scope: offscreen GPU work runs on + * long-lived C++ threads (the surface worker, Nitro's promise pool) that never + * drain a pool of their own. A no-op off Apple. + */ +class AutoreleasePool { + public: +#if defined(__APPLE__) + AutoreleasePool(); + ~AutoreleasePool(); +#else + AutoreleasePool() = default; +#endif + AutoreleasePool(const AutoreleasePool&) = delete; + AutoreleasePool& operator=(const AutoreleasePool&) = delete; + + private: +#if defined(__APPLE__) + void* pool_; +#endif +}; + /** * Holds the shared windowless GPU context for as long as it lives, replacing a * device that lost its context for good. Throws if there is no usable GPU. @@ -35,6 +57,8 @@ class OffscreenContext { } private: + // First, so it outlives the device reference and still drains if the constructor throws. + AutoreleasePool pool_; std::shared_ptr device_; tgfx::Context* context_ = nullptr; }; diff --git a/packages/react-native-tgfx/cpp/Offscreen/OffscreenSurface.cpp b/packages/react-native-tgfx/cpp/Offscreen/OffscreenSurface.cpp index ed58c2ef..38bbf1bd 100644 --- a/packages/react-native-tgfx/cpp/Offscreen/OffscreenSurface.cpp +++ b/packages/react-native-tgfx/cpp/Offscreen/OffscreenSurface.cpp @@ -21,10 +21,6 @@ namespace tgfxrn { -#if defined(__APPLE__) -void renderOffscreenAutoreleased(const std::weak_ptr& next); -#endif - namespace { /** @@ -64,13 +60,9 @@ class OffscreenWorker { next = std::move(queue_.front()); queue_.pop_front(); } -#if defined(__APPLE__) - renderOffscreenAutoreleased(next); -#else if (auto surface = next.lock()) { surface->renderNow(); } -#endif } } diff --git a/packages/react-native-tgfx/cpp/tests/CMakeLists.txt b/packages/react-native-tgfx/cpp/tests/CMakeLists.txt index b25e6fe7..252ef15a 100644 --- a/packages/react-native-tgfx/cpp/tests/CMakeLists.txt +++ b/packages/react-native-tgfx/cpp/tests/CMakeLists.txt @@ -17,7 +17,7 @@ add_executable(SceneTest SceneTest.cpp ../Scene/TgfxScene.cpp ../Path/SvgPath.cp if(APPLE) enable_language(OBJCXX) set_property(TARGET SceneTest PROPERTY OBJCXX_STANDARD 20) - target_sources(SceneTest PRIVATE ../../ios/TgfxOffscreenSurface.mm) + target_sources(SceneTest PRIVATE ../../ios/TgfxAutoreleasePool.mm) target_link_libraries(SceneTest "-framework Foundation") endif() # tgfx's src too: the EXIF test names JpegCodec rather than going through diff --git a/packages/react-native-tgfx/ios/TgfxAutoreleasePool.mm b/packages/react-native-tgfx/ios/TgfxAutoreleasePool.mm new file mode 100644 index 00000000..c6616b0a --- /dev/null +++ b/packages/react-native-tgfx/ios/TgfxAutoreleasePool.mm @@ -0,0 +1,16 @@ +#include "OffscreenRender.hpp" + +// What @autoreleasepool compiles to (Clang's ARC spec, "Runtime support"), +// called directly so the pool can span a C++ scope. +extern "C" void* objc_autoreleasePoolPush(void); +extern "C" void objc_autoreleasePoolPop(void* pool); + +namespace tgfxrn { + +AutoreleasePool::AutoreleasePool() : pool_(objc_autoreleasePoolPush()) {} + +AutoreleasePool::~AutoreleasePool() { + objc_autoreleasePoolPop(pool_); +} + +} // namespace tgfxrn diff --git a/packages/react-native-tgfx/ios/TgfxOffscreenSurface.mm b/packages/react-native-tgfx/ios/TgfxOffscreenSurface.mm deleted file mode 100644 index bd73e8aa..00000000 --- a/packages/react-native-tgfx/ios/TgfxOffscreenSurface.mm +++ /dev/null @@ -1,16 +0,0 @@ -#import - -#include "OffscreenSurface.hpp" - -namespace tgfxrn { - -void renderOffscreenAutoreleased(const std::weak_ptr& next) { - // Detached C++ threads do not drain autoreleased Metal objects themselves. - @autoreleasepool { - if (auto surface = next.lock()) { - surface->renderNow(); - } - } -} - -} // namespace tgfxrn From 26a55111681ff23fed30677183e00df9fa9f377b Mon Sep 17 00:00:00 2001 From: riteshshukla04 Date: Wed, 4 Nov 2026 11:42:42 +0530 Subject: [PATCH 7/7] chore: drop misleading pool ordering comment --- packages/react-native-tgfx/cpp/Offscreen/OffscreenRender.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/react-native-tgfx/cpp/Offscreen/OffscreenRender.hpp b/packages/react-native-tgfx/cpp/Offscreen/OffscreenRender.hpp index 68480166..901096f2 100644 --- a/packages/react-native-tgfx/cpp/Offscreen/OffscreenRender.hpp +++ b/packages/react-native-tgfx/cpp/Offscreen/OffscreenRender.hpp @@ -57,7 +57,6 @@ class OffscreenContext { } private: - // First, so it outlives the device reference and still drains if the constructor throws. AutoreleasePool pool_; std::shared_ptr device_; tgfx::Context* context_ = nullptr;