@shopify/react-native-skia 0.1.183 → 0.1.184

Sign up to get free protection for your applications and to get access to all the features.
@@ -103,11 +103,29 @@ void RNSkMetalCanvasProvider::renderToCanvas(
103
103
  // usage growing very fast in the simulator without this.
104
104
  @autoreleasepool {
105
105
 
106
- GrMTLHandle drawableHandle;
107
- auto skSurface = SkSurface::MakeFromCAMetalLayer(
108
- renderContext->skContext.get(), (__bridge GrMTLHandle)_layer,
109
- kTopLeft_GrSurfaceOrigin, 1, kBGRA_8888_SkColorType, nullptr, nullptr,
110
- &drawableHandle);
106
+ /* It is super important that we use the pattern of calling nextDrawable
107
+ inside this autoreleasepool and not depend on Skia's
108
+ SkSurface::MakeFromCAMetalLayer to encapsulate since we're seeing a lot of
109
+ drawables leaking if they're not done this way.
110
+
111
+ This is now reverted from:
112
+ (https://github.com/Shopify/react-native-skia/commit/2e2290f8e6dfc6921f97b79f779d920fbc1acceb)
113
+ back to the original implementation.
114
+ */
115
+ id<CAMetalDrawable> currentDrawable = [_layer nextDrawable];
116
+ if (currentDrawable == nullptr) {
117
+ return;
118
+ }
119
+
120
+ GrMtlTextureInfo fbInfo;
121
+ fbInfo.fTexture.retain((__bridge void *)currentDrawable.texture);
122
+
123
+ GrBackendRenderTarget backendRT(_layer.drawableSize.width,
124
+ _layer.drawableSize.height, 1, fbInfo);
125
+
126
+ auto skSurface = SkSurface::MakeFromBackendRenderTarget(
127
+ renderContext->skContext.get(), backendRT, kTopLeft_GrSurfaceOrigin,
128
+ kBGRA_8888_SkColorType, nullptr, nullptr);
111
129
 
112
130
  if (skSurface == nullptr || skSurface->getCanvas() == nullptr) {
113
131
  RNSkia::RNSkLogger::logToConsole(
@@ -120,11 +138,8 @@ void RNSkMetalCanvasProvider::renderToCanvas(
120
138
 
121
139
  skSurface->flushAndSubmit();
122
140
 
123
- id<CAMetalDrawable> currentDrawable =
124
- (__bridge id<CAMetalDrawable>)drawableHandle;
125
141
  id<MTLCommandBuffer> commandBuffer(
126
142
  [renderContext->commandQueue commandBuffer]);
127
- commandBuffer.label = @"PresentSkia";
128
143
  [commandBuffer presentDrawable:currentDrawable];
129
144
  [commandBuffer commit];
130
145
  }
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "setup-skia-web": "./scripts/setup-canvaskit.js"
8
8
  },
9
9
  "title": "React Native Skia",
10
- "version": "0.1.183",
10
+ "version": "0.1.184",
11
11
  "description": "High-performance React Native Graphics using Skia",
12
12
  "main": "lib/module/index.js",
13
13
  "files": [