Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ Reducing per-op cost in tgfx's GL backend is where the remaining gap to
- 🟡 **Optional reanimated, for real.** Metro statically bundles the lazily
required driver, so consumers without reanimated fail to bundle. Use the
Skia-style `Proxy`/optional-require or a separate entry point.
- 🟡 RN-version compatibility matrix (currently pinned to RN 0.85 / Nitro 0.35.9).
- 🟡 RN-version compatibility matrix (currently pinned to RN 0.85 / Nitro 0.37.2).

## Rendering engine (features + perf)

Expand Down
2 changes: 1 addition & 1 deletion apps/benchmark/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@react-native/new-app-screen": "0.85.3",
"react-native-safe-area-context": "^5.5.2",
"react-native-tgfx": "workspace:*",
"react-native-nitro-modules": "0.36.5",
"react-native-nitro-modules": "0.37.2",
"react-native-reanimated": "4.5.3",
"react-native-worklets": "0.11.3",
"react-native-gesture-handler": "^3.0.2",
Expand Down
4 changes: 2 additions & 2 deletions apps/example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ PODS:
- ReactCommon/turbomodule/core
- ReactNativeDependencies
- Yoga
- NitroModules (0.36.5):
- NitroModules (0.37.2):
- hermes-engine
- RCTRequired
- RCTTypeSafety
Expand Down Expand Up @@ -2486,7 +2486,7 @@ SPEC CHECKSUMS:
HarnessUI: f439596aec93ff76765451f834c93f966d54e53e
hermes-engine: 58f4822764f3a9815044f59cfb5686c16a84754d
NitroImage: 2f592086cbdecbbaa1c10dd97e0cdd43b1bb0817
NitroModules: 452230d9b63c6c3f59dd97eeaa27ec3449271d4a
NitroModules: 5cd4cd681ddfbf7023b720bb042ff06345acce76
NitroTgfx: c75630aa991b4a7b16fceb0720c65da640960fd9
NitroTgfxCamera: 4829584fec253c1f7c23fdd2b13219ea47870b77
RCTDeprecation: a4c521821fab57cbb125b36effe84d897d0dfa12
Expand Down
2 changes: 1 addition & 1 deletion apps/example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"react-native": "0.85.3",
"react-native-gesture-handler": "^3.0.2",
"react-native-nitro-image": "^0.15.1",
"react-native-nitro-modules": "0.36.5",
"react-native-nitro-modules": "0.37.2",
"react-native-reanimated": "4.5.3",
"react-native-safe-area-context": "^5.5.2",
"react-native-tgfx": "workspace:*",
Expand Down
20 changes: 11 additions & 9 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions docs/content/docs/installation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ icon: Download
npm install react-native-tgfx@alpha react-native-nitro-modules
```

`react-native-nitro-modules` must be 0.37.2 or later.

Animation, camera and video also need `react-native-reanimated` and
`react-native-worklets`.

Expand Down
12 changes: 11 additions & 1 deletion packages/react-native-tgfx/ios/HybridTgfxView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ final class HybridTgfxView: HybridTgfxViewSpec, RecyclableView {
private var boundValues: ArrayBuffer?
// A JS-thread push and the UI-thread driver both bind, so the pointer and its buffer change together.
private let bindLock = NSLock()
// Nitro drops a view right before prepareForRecycle when it pools it, so only a drop without one releases.
private var dropPending = false

var view: UIView { metalView }

Expand All @@ -26,6 +28,7 @@ final class HybridTgfxView: HybridTgfxViewSpec, RecyclableView {
}

func prepareForRecycle() {
dropPending = false
metalView.clearScene()
}

Expand Down Expand Up @@ -131,6 +134,13 @@ final class HybridTgfxView: HybridTgfxViewSpec, RecyclableView {
}

func onDropView() {
metalView.releaseRenderer()
dropPending = true
let metalView = metalView
DispatchQueue.main.async { [weak self] in
// A freed view was never pooled, so it releases too.
if self?.dropPending ?? true {
metalView.releaseRenderer()
}
}
}
}
11 changes: 11 additions & 0 deletions packages/react-native-tgfx/ios/TgfxMetalView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ - (void)commonInit {
_layerConfigPending = false;
_pendingRecycleClear = false;
layer.contentsScale = self.contentScaleFactor;
[self startDisplayLink];
}

- (void)startDisplayLink {
_displayLink = [CADisplayLink displayLinkWithTarget:self
selector:@selector(render)];
[_displayLink addToRunLoop:NSRunLoop.mainRunLoop
Expand Down Expand Up @@ -257,6 +260,12 @@ - (void)didMoveToWindow {
if (self.window == nil && _pendingRecycleClear) {
[self clearSceneNow];
}
// A released view that gets a window again restarts its display link.
if (self.window != nil && _released) {
_released = false;
[self startDisplayLink];
[self wakeUp];
}
}

- (void)setValues:(const double*)values count:(int32_t)count {
Expand Down Expand Up @@ -376,6 +385,8 @@ - (void)releaseRenderer {
}
dispatch_sync(_renderQueue, ^{
self->_renderer->releaseWindow();
// A draw queued before the drop can bind a window again, and a reused view must rebind.
self->_windowBound = false;
});
}

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading