fix(🐘): make Skia contextes per JS runtime not thread local#3715
Open
wcandillon wants to merge 8 commits intoShopify:mainfrom
Open
fix(🐘): make Skia contextes per JS runtime not thread local#3715wcandillon wants to merge 8 commits intoShopify:mainfrom
wcandillon wants to merge 8 commits intoShopify:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the Skia rendering context management to be per JavaScript runtime instance rather than thread-local. This change ensures that each JS runtime maintains its own graphics context, improving isolation and preventing potential issues when multiple runtimes exist.
Changes:
- Removed thread-local singleton patterns from
MetalContext(Apple) andOpenGLContext(Android) in favor of per-instance contexts - Added thread-affinity checks to OpenGL contexts to catch and prevent cross-thread usage
- Updated
WindowContextownership fromunique_ptrtoshared_ptrto support the new architecture
Reviewed changes
Copilot reviewed 17 out of 18 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/skia/cpp/rnskia/RNSkPlatformContext.h | Added useP3ColorSpace parameter to makeContextFromNativeSurface method |
| packages/skia/apple/SkiaCVPixelBufferUtils.mm | Reformatted macro definitions for consistency |
| packages/skia/apple/RNSkMetalCanvasProvider.mm | Removed direct MetalContext::getInstance() calls, now uses platform context |
| packages/skia/apple/RNSkMetalCanvasProvider.h | Changed _ctx from unique_ptr to shared_ptr |
| packages/skia/apple/RNSkApplePlatformContext.mm | Added instance-based metalContext() method replacing singleton pattern |
| packages/skia/apple/RNSkApplePlatformContext.h | Added private MetalContext member and initialization logic |
| packages/skia/apple/MetalContext.h | Removed singleton pattern, made constructor public |
| packages/skia/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.h | Changed _surfaceHolder from unique_ptr to shared_ptr |
| packages/skia/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.cpp | Replaced direct OpenGL context calls with platform context method |
| packages/skia/android/cpp/rnskia-android/RNSkAndroidVideo.h | Added _context member to hold platform context reference |
| packages/skia/android/cpp/rnskia-android/RNSkAndroidVideo.cpp | Updated constructor to accept and use platform context |
| packages/skia/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h | Added getOpenGLContext() method and made class inherit from enable_shared_from_this |
| packages/skia/android/cpp/rnskia-android/OpenGLWindowContext.h | Added thread-affinity checking with assertThread method |
| packages/skia/android/cpp/rnskia-android/OpenGLWindowContext.cpp | Added thread assertions to public methods |
| packages/skia/android/cpp/rnskia-android/OpenGLContext.h | Removed singleton pattern, added thread-affinity checks, moved constructor implementation inline |
| packages/skia/android/cpp/jni/include/JniSkiaPictureView.h | Replaced direct context calls with platform context usage |
| externals/skia | Updated Skia submodule commit |
| apps/example/ios/Podfile.lock | Updated pod dependencies checksums and CocoaPods version |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.