Expand structuredClone compatibility - #58735
Open
rubennorte wants to merge 1 commit into
Open
rubennorte wants to merge 1 commit into
rubennorte wants to merge 1 commit into
Conversation
|
@rubennorte has exported this pull request. If you are a Meta employee, you can view the originating Diff in D122156629. |
rubennorte
added a commit
to rubennorte/react-native
that referenced
this pull request
Sep 29, 2026
Summary: Compare React Native structuredClone with ungap/structured-clone (**used by Expo**) and port the applicable upstream coverage. Add support for ArrayBuffer, DataView, typed arrays, boxed BigInt values, Error subclasses, deeply cloned causes, and safe __proto__ data properties. Serialization-only and JSON/lossy tests remain out of scope because React Native exposes a single-step cloning API. Add ungap/structured-clone as a devDependency and benchmark each existing Fantom scenario against it. Before — React Native implementation before this change: ### structuredClone (mode 🚀) ### | (index) | Task name | Latency avg (ns) | Latency med (ns) | Throughput avg (ops/s) | Throughput med (ops/s) | Samples | | ------- | ------------------------ | ----------------- | ---------------- | ---------------------- | ---------------------- | ------- | | 0 | 'clone a string' | '338.62 ± 0.05%' | '330.00 ± 9.00' | '3014547 ± 0.05%' | '3030303 ± 84962' | 2953184 | | 1 | 'clone a basic array' | '1587.6 ± 10.36%' | '1353.0 ± 19.00' | '734465 ± 0.42%' | '739098 ± 10235' | 638616 | | 2 | 'clone a basic object' | '1344.2 ± 8.81%' | '1172.0 ± 20.00' | '828917 ± 0.33%' | '853242 ± 14813' | 743963 | | 3 | 'clone a complex object' | '3370.6 ± 0.60%' | '3255.0 ± 40.00' | '304183 ± 0.02%' | '307220 ± 3822' | 296680 | After — React Native compared with ungap/structured-clone: ### structuredClone (mode 🚀) ### | (index) | Task name | Latency avg (ns) | Latency med (ns) | Throughput avg (ops/s) | Throughput med (ops/s) | Samples | | ------- | -------------------------------------- | ----------------- | ----------------- | ---------------------- | ---------------------- | ------- | | 0 | 'React Native: clone a string' | '348.44 ± 0.08%' | '331.00 ± 1.00' | '2927181 ± 0.04%' | '3021148 ± 9155' | 2869970 | | 1 | 'ungap: clone a string' | '2037.4 ± 11.17%' | '1592.0 ± 50.00' | '617833 ± 0.09%' | '628141 ± 19947' | 490832 | | 2 | 'React Native: clone a basic array' | '1460.2 ± 8.39%' | '1282.0 ± 20.00' | '775137 ± 0.42%' | '780031 ± 12362' | 684824 | | 3 | 'ungap: clone a basic array' | '5112.8 ± 0.81%' | '4718.0 ± 111.00' | '205586 ± 0.08%' | '211954 ± 5107' | 195589 | | 4 | 'React Native: clone a basic object' | '1373.8 ± 8.58%' | '1152.0 ± 20.00' | '842837 ± 0.46%' | '868056 ± 15337' | 727910 | | 5 | 'ungap: clone a basic object' | '8853.2 ± 0.76%' | '8253.0 ± 141.00' | '117562 ± 0.05%' | '121168 ± 2106' | 112954 | | 6 | 'React Native: clone a complex object' | '3539.4 ± 0.55%' | '3456.0 ± 50.00' | '288368 ± 0.02%' | '289352 ± 4248' | 282537 | | 7 | 'ungap: clone a complex object' | '21498 ± 0.72%' | '20080 ± 301.00' | '48208 ± 0.09%' | '49801 ± 755' | 46516 | The benchmark shows no material regression in the existing implementation and React Native remains faster than ungap/structured-clone across all scenarios. Changelog: [General][Added] - Add ArrayBuffer, DataView, typed array, boxed BigInt, and Error subclass support to structuredClone Differential Revision: D122156629
rubennorte
force-pushed
the
export-D122156629
branch
from
September 29, 2026 11:09
b51a673 to
08978ec
Compare
rubennorte
added a commit
to rubennorte/react-native
that referenced
this pull request
Sep 29, 2026
Summary: Compare React Native structuredClone with ungap/structured-clone (**used by Expo**) and port the applicable upstream coverage. Add support for ArrayBuffer, DataView, typed arrays, boxed BigInt values, Error subclasses, deeply cloned causes, and safe __proto__ data properties. Serialization-only and JSON/lossy tests remain out of scope because React Native exposes a single-step cloning API. Add ungap/structured-clone as a devDependency and benchmark each existing Fantom scenario against it. Before — React Native implementation before this change: ### structuredClone (mode 🚀) ### | (index) | Task name | Latency avg (ns) | Latency med (ns) | Throughput avg (ops/s) | Throughput med (ops/s) | Samples | | ------- | ------------------------ | ----------------- | ---------------- | ---------------------- | ---------------------- | ------- | | 0 | 'clone a string' | '338.62 ± 0.05%' | '330.00 ± 9.00' | '3014547 ± 0.05%' | '3030303 ± 84962' | 2953184 | | 1 | 'clone a basic array' | '1587.6 ± 10.36%' | '1353.0 ± 19.00' | '734465 ± 0.42%' | '739098 ± 10235' | 638616 | | 2 | 'clone a basic object' | '1344.2 ± 8.81%' | '1172.0 ± 20.00' | '828917 ± 0.33%' | '853242 ± 14813' | 743963 | | 3 | 'clone a complex object' | '3370.6 ± 0.60%' | '3255.0 ± 40.00' | '304183 ± 0.02%' | '307220 ± 3822' | 296680 | After — React Native compared with ungap/structured-clone: ### structuredClone (mode 🚀) ### | (index) | Task name | Latency avg (ns) | Latency med (ns) | Throughput avg (ops/s) | Throughput med (ops/s) | Samples | | ------- | -------------------------------------- | ----------------- | ----------------- | ---------------------- | ---------------------- | ------- | | 0 | 'React Native: clone a string' | '348.44 ± 0.08%' | '331.00 ± 1.00' | '2927181 ± 0.04%' | '3021148 ± 9155' | 2869970 | | 1 | 'ungap: clone a string' | '2037.4 ± 11.17%' | '1592.0 ± 50.00' | '617833 ± 0.09%' | '628141 ± 19947' | 490832 | | 2 | 'React Native: clone a basic array' | '1460.2 ± 8.39%' | '1282.0 ± 20.00' | '775137 ± 0.42%' | '780031 ± 12362' | 684824 | | 3 | 'ungap: clone a basic array' | '5112.8 ± 0.81%' | '4718.0 ± 111.00' | '205586 ± 0.08%' | '211954 ± 5107' | 195589 | | 4 | 'React Native: clone a basic object' | '1373.8 ± 8.58%' | '1152.0 ± 20.00' | '842837 ± 0.46%' | '868056 ± 15337' | 727910 | | 5 | 'ungap: clone a basic object' | '8853.2 ± 0.76%' | '8253.0 ± 141.00' | '117562 ± 0.05%' | '121168 ± 2106' | 112954 | | 6 | 'React Native: clone a complex object' | '3539.4 ± 0.55%' | '3456.0 ± 50.00' | '288368 ± 0.02%' | '289352 ± 4248' | 282537 | | 7 | 'ungap: clone a complex object' | '21498 ± 0.72%' | '20080 ± 301.00' | '48208 ± 0.09%' | '49801 ± 755' | 46516 | The benchmark shows no material regression in the existing implementation and React Native remains faster than ungap/structured-clone across all scenarios. Changelog: [General][Added] - Add ArrayBuffer, DataView, typed array, boxed BigInt, and Error subclass support to structuredClone Differential Revision: D122156629
rubennorte
force-pushed
the
export-D122156629
branch
from
September 29, 2026 12:12
08978ec to
1178c5b
Compare
rubennorte
added a commit
to rubennorte/react-native
that referenced
this pull request
Sep 29, 2026
Summary: Compare React Native structuredClone with ungap/structured-clone (**used by Expo**) and port the applicable upstream coverage. Add support for ArrayBuffer, DataView, typed arrays, boxed BigInt values, Error subclasses, deeply cloned causes, and safe __proto__ data properties. Serialization-only and JSON/lossy tests remain out of scope because React Native exposes a single-step cloning API. Add ungap/structured-clone as a devDependency and benchmark each existing Fantom scenario against it. Before — React Native implementation before this change: ### structuredClone (mode 🚀) ### | (index) | Task name | Latency avg (ns) | Latency med (ns) | Throughput avg (ops/s) | Throughput med (ops/s) | Samples | | ------- | ------------------------ | ----------------- | ---------------- | ---------------------- | ---------------------- | ------- | | 0 | 'clone a string' | '338.62 ± 0.05%' | '330.00 ± 9.00' | '3014547 ± 0.05%' | '3030303 ± 84962' | 2953184 | | 1 | 'clone a basic array' | '1587.6 ± 10.36%' | '1353.0 ± 19.00' | '734465 ± 0.42%' | '739098 ± 10235' | 638616 | | 2 | 'clone a basic object' | '1344.2 ± 8.81%' | '1172.0 ± 20.00' | '828917 ± 0.33%' | '853242 ± 14813' | 743963 | | 3 | 'clone a complex object' | '3370.6 ± 0.60%' | '3255.0 ± 40.00' | '304183 ± 0.02%' | '307220 ± 3822' | 296680 | After — React Native compared with ungap/structured-clone: ### structuredClone (mode 🚀) ### | (index) | Task name | Latency avg (ns) | Latency med (ns) | Throughput avg (ops/s) | Throughput med (ops/s) | Samples | | ------- | -------------------------------------- | ----------------- | ----------------- | ---------------------- | ---------------------- | ------- | | 0 | 'React Native: clone a string' | '348.44 ± 0.08%' | '331.00 ± 1.00' | '2927181 ± 0.04%' | '3021148 ± 9155' | 2869970 | | 1 | 'ungap: clone a string' | '2037.4 ± 11.17%' | '1592.0 ± 50.00' | '617833 ± 0.09%' | '628141 ± 19947' | 490832 | | 2 | 'React Native: clone a basic array' | '1460.2 ± 8.39%' | '1282.0 ± 20.00' | '775137 ± 0.42%' | '780031 ± 12362' | 684824 | | 3 | 'ungap: clone a basic array' | '5112.8 ± 0.81%' | '4718.0 ± 111.00' | '205586 ± 0.08%' | '211954 ± 5107' | 195589 | | 4 | 'React Native: clone a basic object' | '1373.8 ± 8.58%' | '1152.0 ± 20.00' | '842837 ± 0.46%' | '868056 ± 15337' | 727910 | | 5 | 'ungap: clone a basic object' | '8853.2 ± 0.76%' | '8253.0 ± 141.00' | '117562 ± 0.05%' | '121168 ± 2106' | 112954 | | 6 | 'React Native: clone a complex object' | '3539.4 ± 0.55%' | '3456.0 ± 50.00' | '288368 ± 0.02%' | '289352 ± 4248' | 282537 | | 7 | 'ungap: clone a complex object' | '21498 ± 0.72%' | '20080 ± 301.00' | '48208 ± 0.09%' | '49801 ± 755' | 46516 | The benchmark shows no material regression in the existing implementation and React Native remains faster than ungap/structured-clone across all scenarios. Changelog: [General][Added] - Add ArrayBuffer, DataView, typed array, boxed BigInt, and Error subclass support to structuredClone Differential Revision: D122156629
rubennorte
force-pushed
the
export-D122156629
branch
from
September 29, 2026 12:35
1178c5b to
2d237d0
Compare
rubennorte
added a commit
to rubennorte/react-native
that referenced
this pull request
Sep 29, 2026
Summary: Compare React Native structuredClone with ungap/structured-clone (**used by Expo**) and port the applicable upstream coverage. Add support for ArrayBuffer, DataView, typed arrays, boxed BigInt values, Error subclasses, deeply cloned causes, and safe __proto__ data properties. Serialization-only and JSON/lossy tests remain out of scope because React Native exposes a single-step cloning API. Add ungap/structured-clone as a devDependency and benchmark each existing Fantom scenario against it. Before — React Native implementation before this change: ### structuredClone (mode 🚀) ### | (index) | Task name | Latency avg (ns) | Latency med (ns) | Throughput avg (ops/s) | Throughput med (ops/s) | Samples | | ------- | ------------------------ | ----------------- | ---------------- | ---------------------- | ---------------------- | ------- | | 0 | 'clone a string' | '338.62 ± 0.05%' | '330.00 ± 9.00' | '3014547 ± 0.05%' | '3030303 ± 84962' | 2953184 | | 1 | 'clone a basic array' | '1587.6 ± 10.36%' | '1353.0 ± 19.00' | '734465 ± 0.42%' | '739098 ± 10235' | 638616 | | 2 | 'clone a basic object' | '1344.2 ± 8.81%' | '1172.0 ± 20.00' | '828917 ± 0.33%' | '853242 ± 14813' | 743963 | | 3 | 'clone a complex object' | '3370.6 ± 0.60%' | '3255.0 ± 40.00' | '304183 ± 0.02%' | '307220 ± 3822' | 296680 | After — React Native compared with ungap/structured-clone: ### structuredClone (mode 🚀) ### | (index) | Task name | Latency avg (ns) | Latency med (ns) | Throughput avg (ops/s) | Throughput med (ops/s) | Samples | | ------- | -------------------------------------- | ----------------- | ----------------- | ---------------------- | ---------------------- | ------- | | 0 | 'React Native: clone a string' | '348.44 ± 0.08%' | '331.00 ± 1.00' | '2927181 ± 0.04%' | '3021148 ± 9155' | 2869970 | | 1 | 'ungap: clone a string' | '2037.4 ± 11.17%' | '1592.0 ± 50.00' | '617833 ± 0.09%' | '628141 ± 19947' | 490832 | | 2 | 'React Native: clone a basic array' | '1460.2 ± 8.39%' | '1282.0 ± 20.00' | '775137 ± 0.42%' | '780031 ± 12362' | 684824 | | 3 | 'ungap: clone a basic array' | '5112.8 ± 0.81%' | '4718.0 ± 111.00' | '205586 ± 0.08%' | '211954 ± 5107' | 195589 | | 4 | 'React Native: clone a basic object' | '1373.8 ± 8.58%' | '1152.0 ± 20.00' | '842837 ± 0.46%' | '868056 ± 15337' | 727910 | | 5 | 'ungap: clone a basic object' | '8853.2 ± 0.76%' | '8253.0 ± 141.00' | '117562 ± 0.05%' | '121168 ± 2106' | 112954 | | 6 | 'React Native: clone a complex object' | '3539.4 ± 0.55%' | '3456.0 ± 50.00' | '288368 ± 0.02%' | '289352 ± 4248' | 282537 | | 7 | 'ungap: clone a complex object' | '21498 ± 0.72%' | '20080 ± 301.00' | '48208 ± 0.09%' | '49801 ± 755' | 46516 | The benchmark shows no material regression in the existing implementation and React Native remains faster than ungap/structured-clone across all scenarios. Changelog: [General][Added] - Add ArrayBuffer, DataView, typed array, boxed BigInt, and Error subclass support to structuredClone Differential Revision: D122156629
rubennorte
force-pushed
the
export-D122156629
branch
from
September 29, 2026 15:35
2d237d0 to
bbb0a6c
Compare
Summary: Compare React Native structuredClone behavior with ungap/structured-clone and port the applicable upstream coverage. Add support for ArrayBuffer, DataView, typed arrays, boxed BigInt values, Error subclasses, deeply cloned causes, and safe __proto__ data properties. Serialization-only and JSON/lossy tests remain out of scope because React Native exposes a single-step cloning API. The comparison dependency and benchmark cases were used only to collect the results below and are not shipped with React Native. Before — React Native implementation before this change: ### structuredClone (mode 🚀) ### | (index) | Task name | Latency avg (ns) | Latency med (ns) | Throughput avg (ops/s) | Throughput med (ops/s) | Samples | | ------- | ------------------------ | ----------------- | ---------------- | ---------------------- | ---------------------- | ------- | | 0 | 'clone a string' | '338.62 ± 0.05%' | '330.00 ± 9.00' | '3014547 ± 0.05%' | '3030303 ± 84962' | 2953184 | | 1 | 'clone a basic array' | '1587.6 ± 10.36%' | '1353.0 ± 19.00' | '734465 ± 0.42%' | '739098 ± 10235' | 638616 | | 2 | 'clone a basic object' | '1344.2 ± 8.81%' | '1172.0 ± 20.00' | '828917 ± 0.33%' | '853242 ± 14813' | 743963 | | 3 | 'clone a complex object' | '3370.6 ± 0.60%' | '3255.0 ± 40.00' | '304183 ± 0.02%' | '307220 ± 3822' | 296680 | After — React Native compared with ungap/structured-clone: ### structuredClone (mode 🚀) ### | (index) | Task name | Latency avg (ns) | Latency med (ns) | Throughput avg (ops/s) | Throughput med (ops/s) | Samples | | ------- | -------------------------------------- | ----------------- | ----------------- | ---------------------- | ---------------------- | ------- | | 0 | 'React Native: clone a string' | '348.44 ± 0.08%' | '331.00 ± 1.00' | '2927181 ± 0.04%' | '3021148 ± 9155' | 2869970 | | 1 | 'ungap: clone a string' | '2037.4 ± 11.17%' | '1592.0 ± 50.00' | '617833 ± 0.09%' | '628141 ± 19947' | 490832 | | 2 | 'React Native: clone a basic array' | '1460.2 ± 8.39%' | '1282.0 ± 20.00' | '775137 ± 0.42%' | '780031 ± 12362' | 684824 | | 3 | 'ungap: clone a basic array' | '5112.8 ± 0.81%' | '4718.0 ± 111.00' | '205586 ± 0.08%' | '211954 ± 5107' | 195589 | | 4 | 'React Native: clone a basic object' | '1373.8 ± 8.58%' | '1152.0 ± 20.00' | '842837 ± 0.46%' | '868056 ± 15337' | 727910 | | 5 | 'ungap: clone a basic object' | '8853.2 ± 0.76%' | '8253.0 ± 141.00' | '117562 ± 0.05%' | '121168 ± 2106' | 112954 | | 6 | 'React Native: clone a complex object' | '3539.4 ± 0.55%' | '3456.0 ± 50.00' | '288368 ± 0.02%' | '289352 ± 4248' | 282537 | | 7 | 'ungap: clone a complex object' | '21498 ± 0.72%' | '20080 ± 301.00' | '48208 ± 0.09%' | '49801 ± 755' | 46516 | The benchmark shows no material regression in the existing implementation and React Native remains faster than ungap/structured-clone across all scenarios. Changelog: [General][Added] - Add ArrayBuffer, DataView, typed array, boxed BigInt, and Error subclass support to structuredClone Reviewed By: javache Differential Revision: D122156629
rubennorte
force-pushed
the
export-D122156629
branch
from
September 29, 2026 15:39
bbb0a6c to
58b2f9b
Compare
rubennorte
added a commit
to rubennorte/react-native
that referenced
this pull request
Sep 29, 2026
Summary: Compare React Native structuredClone behavior with ungap/structured-clone and port the applicable upstream coverage. Add support for ArrayBuffer, DataView, typed arrays, boxed BigInt values, Error subclasses, deeply cloned causes, and safe __proto__ data properties. Serialization-only and JSON/lossy tests remain out of scope because React Native exposes a single-step cloning API. The comparison dependency and benchmark cases were used only to collect the results below and are not shipped with React Native. Before — React Native implementation before this change: ### structuredClone (mode 🚀) ### | (index) | Task name | Latency avg (ns) | Latency med (ns) | Throughput avg (ops/s) | Throughput med (ops/s) | Samples | | ------- | ------------------------ | ----------------- | ---------------- | ---------------------- | ---------------------- | ------- | | 0 | 'clone a string' | '338.62 ± 0.05%' | '330.00 ± 9.00' | '3014547 ± 0.05%' | '3030303 ± 84962' | 2953184 | | 1 | 'clone a basic array' | '1587.6 ± 10.36%' | '1353.0 ± 19.00' | '734465 ± 0.42%' | '739098 ± 10235' | 638616 | | 2 | 'clone a basic object' | '1344.2 ± 8.81%' | '1172.0 ± 20.00' | '828917 ± 0.33%' | '853242 ± 14813' | 743963 | | 3 | 'clone a complex object' | '3370.6 ± 0.60%' | '3255.0 ± 40.00' | '304183 ± 0.02%' | '307220 ± 3822' | 296680 | After — React Native compared with ungap/structured-clone: ### structuredClone (mode 🚀) ### | (index) | Task name | Latency avg (ns) | Latency med (ns) | Throughput avg (ops/s) | Throughput med (ops/s) | Samples | | ------- | -------------------------------------- | ----------------- | ----------------- | ---------------------- | ---------------------- | ------- | | 0 | 'React Native: clone a string' | '348.44 ± 0.08%' | '331.00 ± 1.00' | '2927181 ± 0.04%' | '3021148 ± 9155' | 2869970 | | 1 | 'ungap: clone a string' | '2037.4 ± 11.17%' | '1592.0 ± 50.00' | '617833 ± 0.09%' | '628141 ± 19947' | 490832 | | 2 | 'React Native: clone a basic array' | '1460.2 ± 8.39%' | '1282.0 ± 20.00' | '775137 ± 0.42%' | '780031 ± 12362' | 684824 | | 3 | 'ungap: clone a basic array' | '5112.8 ± 0.81%' | '4718.0 ± 111.00' | '205586 ± 0.08%' | '211954 ± 5107' | 195589 | | 4 | 'React Native: clone a basic object' | '1373.8 ± 8.58%' | '1152.0 ± 20.00' | '842837 ± 0.46%' | '868056 ± 15337' | 727910 | | 5 | 'ungap: clone a basic object' | '8853.2 ± 0.76%' | '8253.0 ± 141.00' | '117562 ± 0.05%' | '121168 ± 2106' | 112954 | | 6 | 'React Native: clone a complex object' | '3539.4 ± 0.55%' | '3456.0 ± 50.00' | '288368 ± 0.02%' | '289352 ± 4248' | 282537 | | 7 | 'ungap: clone a complex object' | '21498 ± 0.72%' | '20080 ± 301.00' | '48208 ± 0.09%' | '49801 ± 755' | 46516 | The benchmark shows no material regression in the existing implementation and React Native remains faster than ungap/structured-clone across all scenarios. Changelog: [General][Added] - Add ArrayBuffer, DataView, typed array, boxed BigInt, and Error subclass support to structuredClone Reviewed By: javache Differential Revision: D122156629
This branch has not been deployed
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.
Summary:
Compare React Native structuredClone behavior with ungap/structured-clone and port the applicable upstream coverage. Add support for ArrayBuffer, DataView, typed arrays, boxed BigInt values, Error subclasses, deeply cloned causes, and safe proto data properties. Serialization-only and JSON/lossy tests remain out of scope because React Native exposes a single-step cloning API.
The comparison dependency and benchmark cases were used only to collect the results below and are not shipped with React Native.
Before — React Native implementation before this change:
structuredClone (mode 🚀)
After — React Native compared with ungap/structured-clone:
structuredClone (mode 🚀)
The benchmark shows no material regression in the existing implementation and React Native remains faster than ungap/structured-clone across all scenarios.
Changelog:
[General][Added] - Add ArrayBuffer, DataView, typed array, boxed BigInt, and Error subclass support to structuredClone
Reviewed By: javache
Differential Revision: D122156629