Skip to content

fix: Disable wasm reference-types for compatibility with devices like iOS 16#946

Merged
zxch3n merged 2 commits intomainfrom
codex/fix-wasm-reference-types-ios
Apr 12, 2026
Merged

fix: Disable wasm reference-types for compatibility with devices like iOS 16#946
zxch3n merged 2 commits intomainfrom
codex/fix-wasm-reference-types-ios

Conversation

@zxch3n
Copy link
Copy Markdown
Member

@zxch3n zxch3n commented Apr 12, 2026

Summary

  • Strip the target_features custom section from the raw loro_wasm.wasm before running wasm-bindgen, so generated JS falls back to slab-based object handles instead of externref table glue.
  • Add a reusable strip-custom command to loro-wasm-tools and use it in the loro-wasm build pipeline.
  • Remove the old bundler externref table initialization patch, which is no longer needed after forcing slab mode.

Root Cause

wasm-bindgen 0.2.100 reads the wasm target_features custom section. When it sees +reference-types, it emits externref table glue. Safari 16.0-16.3 lacks WebAssembly reference-types support, which can surface as an out-of-bounds table access trap.

Validation

  • git diff --check
  • cargo check -p loro-wasm-tools
  • pnpm -C crates/loro-wasm build-release
  • Verified release artifacts contain 0 matches for externref, addToExternrefTable, and __wbindgen_init_externref_table across bundler, nodejs, web, and base64 outputs.
  • Verified release wasm binaries contain 0 matches for target_features and reference-types.

@zxch3n zxch3n changed the title [codex] fix wasm reference-types for iOS 16 fix: wasm reference-types for compatibility like iOS 16 Apr 12, 2026
@zxch3n zxch3n marked this pull request as ready for review April 12, 2026 13:34
@zxch3n zxch3n changed the title fix: wasm reference-types for compatibility like iOS 16 fix: Disable wasm reference-types for compatibility with devices like iOS 16 Apr 12, 2026
@github-actions
Copy link
Copy Markdown
Contributor

WASM Size Report

  • Original size: 3138.80 KB
  • Gzipped size: 992.67 KB
  • Brotli size: 689.87 KB

@zxch3n zxch3n merged commit 33d5e51 into main Apr 12, 2026
1 check passed
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.

1 participant