<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Tomasz J. Żelawski on Medium]]></title>
        <description><![CDATA[Stories by Tomasz J. Żelawski on Medium]]></description>
        <link>https://medium.com/@tzelawski?source=rss-edd4b1f8cb14------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*GB1ZjmZF2iGnf46G</url>
            <title>Stories by Tomasz J. Żelawski on Medium</title>
            <link>https://medium.com/@tzelawski?source=rss-edd4b1f8cb14------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 09:10:51 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tzelawski/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Worklets 0.8: The Shareable — Shared Memory’s Missing Piece]]></title>
            <link>https://medium.com/swmansion/worklets-0-8-the-shareable-shared-memorys-missing-piece-d8880d4f2e7b?source=rss-edd4b1f8cb14------2</link>
            <guid isPermaLink="false">https://medium.com/p/d8880d4f2e7b</guid>
            <category><![CDATA[multithreading]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[react-native-worklets]]></category>
            <dc:creator><![CDATA[Tomasz J. Żelawski]]></dc:creator>
            <pubDate>Thu, 19 Mar 2026 16:03:17 GMT</pubDate>
            <atom:updated>2026-03-19T16:03:17.189Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u-8goh4xWOB8mVzdeTlcjA.png" /></figure><p><strong>TL;DR:</strong> Worklets 0.8.0 introduces <a href="https://docs.swmansion.com/react-native-worklets/docs/memory/shareable">the Shareable</a> — a runtime-bound shared memory primitive that powers Reanimated’s Shared Values under the hood. Now it’s available as a lean standalone building block for your own use cases.</p><h3>Sharing JavaScript memory in React Native</h3><p>Sharing memory between JavaScript Runtimes in React Native is difficult. Not only do we have to overcome the limitations of the single-threaded paradigm of JavaScript, but also cover the API needs of typical React Native apps.</p><p>Today we present to you <strong>the Shareable, the last missing shared memory data type in React Native Worklets</strong>. But before we dive into the Shareable itself, let’s take a look at what exactly the other data types are.</p><h3>3 types of shared memory</h3><p>Since every JavaScript Runtime has its own memory space, which by design can’t be accessed from another Runtime’s memory space, we must add intermediate steps, with C++ and JSI — JavaScript Native Interface — that will create a bridge connecting these memory spaces. That way we can create an illusion that even though the memory spaces are totally disjoint, there’s some kind of link between them</p><p>We can distinguish three different types of shared memory, based on their use case:</p><h4>Copy-only memory</h4><p>The simplest of them all, a way to move any value from Runtime A to Runtime B as-is: a number, an object, a string, basically everything that makes sense. However, changes to such a value on any Runtime aren’t reflected in the other Runtimes. <strong>Each Runtime is unaware that it has a copy and simply treats its value as the original</strong>. This is the<strong> </strong><a href="https://docs.swmansion.com/react-native-worklets/docs/memory/serializable">Serializable</a>. <em>Depending on the definition of shared memory, this type might not even be considered one.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DloG-NwpScus7DMoH2NQbA.png" /><figcaption>Serializable copy-only memory model</figcaption></figure><h4>Unbound memory</h4><p>The first type of memory that is actually shared — meaning that changes to it on Runtime A will be seen by Runtime B and all the other Runtimes. This is achieved by keeping the actual “real” value outside of any Runtime, in C++, guarded by mutexes and other thread-safe mechanisms. Each JavaScript Runtime holds just a specific kind of reference to the C++ value. <strong>Each read or write means crossing the boundary between JavaScript and C++</strong>. Because the memory is thread-safe, each Runtime can safely access it at its own discretion. This is the <a href="https://docs.swmansion.com/react-native-worklets/docs/memory/synchronizable">Synchronizable</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*50jfAwloDXgCx-4X_eCcog.png" /><figcaption>Synchronizable unbound memory model</figcaption></figure><h4>Runtime-bound memory</h4><p>Type of asymmetric shared memory that overcomes some issues of unbound memory — operations on unbound memory are much more expensive than ones on plain JavaScript values — due to the need to cross the boundary between JavaScript and C++ with JSI on each access. <strong>Runtime-bound memory optimizes access time on a single designated JavaScript Runtime</strong>, called the Host Runtime, by simply holding the value there as a plain JavaScript value. Other Runtimes only have a specific kind of reference that “knows” that the actual value lives on another Runtime — if you want to access it with that reference, you must go to C++, obtain the Host Runtime exclusively, read the actual value, and return it all the way back to the accessor Runtime. This is the <a href="https://docs.swmansion.com/react-native-worklets/docs/memory/shareable">Shareable</a>, the spotlight of today’s blogpost.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2kuGf2kYybR95zAOAR0o2Q.png" /><figcaption>Shareable runtime-bound memory model</figcaption></figure><h3>Why Shared Value wasn’t enough</h3><p>The Shareable is by far the most complicated type of memory available in Worklets. You might wonder what purpose such a complicated concept could possibly serve. It turns out it has been there, in React Native, for years — this is exactly how <a href="https://docs.swmansion.com/react-native-reanimated/docs/core/useSharedValue/">Reanimated’s Shared Value</a> (also called the Mutable) works. <strong>A Shared Value is a runtime-bound type of shared memory, specifically tailored for reactivity and driving animations.</strong> It lives on the <a href="https://docs.swmansion.com/react-native-worklets/docs/fundamentals/runtimeKinds/#ui-runtime">UI Runtime</a> where it’s updated and read sometimes even hundreds of times per frame in apps with a lot of animations. When you assign a new animation to it in your component, you actually schedule a call to the UI Runtime with your specific reference, where you update the value — and your animation is also copied to the UI Runtime, as a Serializable.</p><p>We wanted to go a step further with the Shared Value, expanding the possibilities of what you can do with shared memory in your apps. <strong>However, Shared Value’s close relation to animations and the UI Runtime proved to be a serious obstacle when trying to use it in a non-animation use case</strong>. This is why we had to take a step back, separate the shared memory concept from the animation logic, and expose a building block which Reanimated can take and turn into a Shared Value by adding animations to it. The same building block that you can take and do whatever you want with. This building block, the shared memory “primitive”, is the Shareable.</p><p><strong>With React Native Worklets 0.8.0, you can freely use the Shareable in your apps, simplify some of your Shared Value use cases, and even create your own custom shared memory types by building on top of the Shareable. It’s all in your hands now, so go ahead and experiment with it!</strong></p><p>We’re <a href="https://swmansion.com/">Software Mansion</a>: multimedia experts, AI explorers, React Native core contributors, community builders, and software development consultants.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d8880d4f2e7b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swmansion/worklets-0-8-the-shareable-shared-memorys-missing-piece-d8880d4f2e7b">Worklets 0.8: The Shareable — Shared Memory’s Missing Piece</a> was originally published in <a href="https://medium.com/swmansion">Software Mansion</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Behind the Scenes of React Native Multithreading: Vision Camera V5 x React Native Worklets]]></title>
            <link>https://medium.com/swmansion/behind-the-scenes-of-react-native-multithreading-vision-camera-v5-x-react-native-worklets-a102c37b32ae?source=rss-edd4b1f8cb14------2</link>
            <guid isPermaLink="false">https://medium.com/p/a102c37b32ae</guid>
            <category><![CDATA[react-native-worklets]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[multithreading]]></category>
            <dc:creator><![CDATA[Tomasz J. Żelawski]]></dc:creator>
            <pubDate>Thu, 29 Jan 2026 15:35:27 GMT</pubDate>
            <atom:updated>2026-01-30T13:15:42.165Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4KAuH716fi9DUScwVQ3iGg.png" /></figure><p>If you’ve been working with React Native for a while, you’ve probably hit a wall where animations, gestures, or app performance <em>should</em> have been smooth, but weren’t.</p><p>For a long time, React Native developers had to choose between developer comfort and performance. JavaScript was easy and expressive, but pushing it too far was challenging. <strong>As apps grew more ambitious, adding real‑time camera features, advanced graphics, or audio processing, it became clear that we needed better tools for concurrency.</strong></p><p>In this article, we tell the story of how the React Native Worklets library was born, what it does, what it brings to the ecosystem, and how it powers tools like the new VisionCamera v5. Let’s dive in!</p><h3>How React Native Worklets was born</h3><p>At first <a href="https://docs.swmansion.com/react-native-worklets/">React Native Worklets</a> wasn’t a separate project. The library was originally developed as an internal component for tools like <a href="https://docs.swmansion.com/react-native-reanimated">React Native Reanimated</a> or <a href="https://docs.swmansion.com/react-native-gesture-handler/">React Native Gesture Handler</a>, allowing developers to create smooth animations and interactions that felt truly native.</p><p>In the early days of React Native, your animation logic would exist solely in JavaScript, running on the same thread, the JS thread, as the React part of your application. This meant that any expensive operation, such as data processing, network activity, or even unrelated JavaScript work, could negatively impact animation performance. Reanimated addressed this by introducing a way to execute animation logic outside of React’s render cycle, safe from JS thread bottlenecks.</p><p><strong>The technical mechanism behind this approach became known as <em>worklets</em> — small, isolated pieces of JavaScript code designed to run on the UI thread, on a separate JavaScript runtime.</strong> They had a restricted execution environment by design, which made their behavior predictable and safe to run concurrently.</p><p>An example of how worklets can be used to react to gestures synchronously on the UI thread to trigger animations and layout changes:</p><pre>const pan = Gesture.Pan()<br>    .onChange((event) =&gt; {<br>      &#39;worklet&#39;;<br>      offset.value = event.translationX;<br>    })<br>    .onFinalize(() =&gt; {<br>      &#39;worklet&#39;;<br>      offset.value = withSpring(0);<br>    });</pre><p>As Reanimated evolved, it became clear that this execution model was useful far beyond animations. <strong>The same characteristics that made worklets good for animations (low latency, independence from React, and concurrent execution) also applied to gesture handling, graphics rendering, camera frame processing, audio processing, and other performance-critical tasks.</strong></p><p>For example, react-native-vision-camera introduced “Frame Processors” — a mechanism to run a JS function on every Frame the Camera “sees”:</p><pre>```ts<br>const frameProcessor = useFrameProcessor((frame) =&gt; {<br>  &#39;worklet&#39;<br>  const objects = detectObjects(frame)<br>  const label = objects[0].name<br>  console.log(`You&#39;re looking at a ${label}.`)<br>}, [])<br>return &lt;Camera frameProcessor={frameProcessor} /&gt;<br>```</pre><p>At that point, worklets started to outgrow their original context. Developers and library authors needed access to multithreading capabilities even when animations weren’t involved. So, <strong>we realized that keeping worklets tightly coupled to Reanimated equaled unnecessary dependencies and limited adoption.</strong></p><p><strong>Extracting worklets into a standalone library was a practical decision that allowed us to focus more on multithreading and provide a general-purpose solution for concurrency in React Native.</strong></p><h3>React Native Worklets as a multithreading engine</h3><p>Today, <strong>React Native Worklets enables full-scale multithreading within the React Native framework. </strong>You can think of it as an engine that lets you run JavaScript logic concurrently, without writing native code.</p><p>The key idea is simple: purely native apps can utilize multiple CPU cores to increase performance — this should be easily done in React Native too. Heavy calculations, continuous processing, or real-time data handling don’t have to execute within your components. <strong>With React Native Worklets, you define what pieces of your JavaScript code should run independently, keeping your UI responsive and predictable.</strong></p><p>Thanks to it, instead of jumping into native modules or complex bridges, developers can stay in JavaScript and use familiar APIs. This is exactly why worklets are such a good fit for many specialized libraries.</p><h3>Integrating React Native Worklets and VisionCamera</h3><blockquote>react-native-vision-camera (often referred to simply as “VisionCamera”) is a powerful, high-performance Camera library for React Native. Next to photo, video, or snapshot capture, it also supports real-time “Frame Processing” via useFrameProcessor(…).</blockquote><blockquote>Since the Camera runs on a separate Camera Thread, VisionCamera conventionally would have to perform a Thread-hop to call the JS Frame Processor, which can cause stalling, or even worse — requires serialization for a Frame — at 4k, that is ~33MB per Frame, or ~1GB/s.</blockquote><blockquote>Thanks to <em>worklets</em>, VisionCamera instead synchronously calls your JS Frame Processor on the Camera Thread without a Thread-hop nor serialization! <strong>Without worklets, VisionCamera Frame Processors would’ve never existed.</strong></blockquote><blockquote>As a user, you don’t need to configure anything — if react-native-worklets is installed, VisionCamera V5 can use it automatically thanks to <a href="https://github.com/mrousavy/nitro/blob/main/packages/react-native-nitro-modules/src/worklets/installWorkletsSupport.ts">Nitro’s worklets integration</a>.</blockquote><h3>What’s next?</h3><p>The react-native-worklets library is still young, and there’s plenty of room to grow. We’re actively working on making it easier to adopt, as multithreading shouldn’t feel like an advanced trick; it should be something devs reach for naturally when they want to improve app performance.</p><p>We’re also really excited to see what the community will build on this foundation. Rendering, audio, automation, and real-time processing: these are all areas where react-native-worklets can simplify work and make limitations disappear. So, take a look at our docs and <a href="https://docs.swmansion.com/react-native-worklets/docs/">get started</a>!</p><p>We’re <a href="https://swmansion.com/">Software Mansion</a>: multimedia experts, AI explorers, React Native core contributors, community builders, and software development consultants.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a102c37b32ae" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swmansion/behind-the-scenes-of-react-native-multithreading-vision-camera-v5-x-react-native-worklets-a102c37b32ae">Behind the Scenes of React Native Multithreading: Vision Camera V5 x React Native Worklets</a> was originally published in <a href="https://medium.com/swmansion">Software Mansion</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>