Skip to content

fix(🐘): make Skia contextes per JS runtime not thread local#3715

Open
wcandillon wants to merge 8 commits intoShopify:mainfrom
wcandillon:jsruntime-contextes
Open

fix(🐘): make Skia contextes per JS runtime not thread local#3715
wcandillon wants to merge 8 commits intoShopify:mainfrom
wcandillon:jsruntime-contextes

Conversation

@wcandillon
Copy link
Contributor

No description provided.

@wcandillon wcandillon requested a review from Copilot February 18, 2026 10:24
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) and OpenGLContext (Android) in favor of per-instance contexts
  • Added thread-affinity checks to OpenGL contexts to catch and prevent cross-thread usage
  • Updated WindowContext ownership from unique_ptr to shared_ptr to 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.

@wcandillon wcandillon changed the title fix(🐘): make Skia contextes per JS-runtimes not thread local fix(🐘): make Skia contextes per JS runtime not thread local Feb 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants