* wip
* Handle wasm data segments and manage brotli artifacts
Add full support for parsing, encoding and rewriting Wasm data segments: introduce WasmDataSegmentKind (Active/Passive), helpers to encode varints and const i32 exprs, and functions to rewrite the data section or replace a section payload. Update wasm_split_data_segments to preserve passive segments and data.count (section 12), only extract active segments into a separate split blob, and adjust segment counting and tests accordingly.
Bump brotli dependency to 8.0 in tools, and add remove_brotli_artifact to remove leftover .br files when brotli compression is disabled. Call this cleanup in cargo_makepad build/copy paths and when removing split data, and add .bin MIME mapping and print mapping for .bin in the server output. Tests updated to cover passive segments and data_count preservation.
* Support split data v2 and wasm rebuild
Add support for a new split data format (version 2) and the ability to rebuild a WASM module with its data section. wasm_bridge.js: parse v1/v2 split blobs, return {version, segments}, add varint encode/decode helpers, encode split-data section payloads, implement rebuild_split_wasm, fetch-and-instantiate logic to fetch both wasm and split blobs and handle v1 preloaded splits or rebuild for v2. wasm_strip.rs: bump split data version to 2, include segment kind and memory_index in encoded split data, preserve passive segments, update encoding/decoding and tests, and return the updated segment count. tools/cargo_makepad/src/wasm/compile.rs: separate target spec directories for threaded vs single builds (threads/single).
* basic splitting
* Instantiate secondary Wasm module in threads
Store and expose a compiled secondary WebAssembly module from the primary module, and ensure worker contexts (Web Worker and AudioWorklet) instantiate that secondary module before running thread entrypoints. Changes: save _secondary_module on primary_wasm in wasm_bridge, include secondary_module in WasmWebBrowser info, and add async instantiate_secondary logic + awaits in audio_worklet and web_worker so the secondary module is instantiated with {env, primary: primary_wasm.exports} prior to initializing stack/TLS or starting execution. This ensures the secondary module can import primary exports in threaded contexts and prevents race conditions by waiting for instantiation to complete.
* more cleanups
* more cleanup
* wip
* remove double wasm pump
* cleanup
* Cold-first auto wasm split with fallback
Add a cold-only function-splitting mode and automatic fallback to preserve startup-safe behavior. Introduces wasm_split_functions_cold() and a split_auto flag to run a cold-first pass that moves defer-safe cold functions to a secondary wasm; if no useful cold candidates are found the build falls back to the normal startup-path function split so the app still gets a secondary payload.
Changes include: update to CLI help text, new split_auto handling in WasmConfig, AutoSplitOutcome variants, compile logic to prefer cold-only splits then fall back to the regular split, adjusted logging for automatic mode, and README wording clarifications. Files touched: README.md, libs/wasm_strip/src/wasm_strip.rs, tools/cargo_makepad/src/main.rs, tools/cargo_makepad/src/wasm/compile.rs, tools/cargo_makepad/src/wasm/mod.rs.
* Tune brotli compression parameters
Adjust brotli settings in tools/cargo_makepad/src/wasm/compile.rs: increase buffer size from 4KB to 64KB, lower quality from 12 to 11, and raise window size from 22 to 24. This balances throughput and compression ratio for larger wasm artifacts—bigger buffer and window can improve compression effectiveness while slightly reducing CPU cost by lowering quality.
* Add optional wasm-opt optimization flag
Introduce an optional --wasm-opt option that runs Binaryen's wasm-opt -Os on built wasm when available. Adds a wasm_opt flag to WasmConfig (default false), parses the CLI option, and integrates a try_wasm_opt helper that writes a temp wasm, invokes wasm-opt, reads back the optimized output and prints size/reporting while gracefully falling back on errors. The wasm-opt step runs before the existing split/strip pipeline. Also updates CLI help text, minor Cargo.toml formatting changes, and removes a vendor UPSTREAM.md reference.
* update readme
* Shorten split exports to $s/$p and use base62
Rename split-related exports/imports to shorter identifiers and compress numeric indices using base62. Changes: export/table slot prefix changed from "__mp_split_table"/"__mp_split_slot_*" to "$s" and the primary import namespace from "primary" to "$p" across wasm_bridge, audio_worklet, and web_worker. Introduces encode_base62 in wasm_strip to emit $f/$t/$m/$g names with base62-encoded indices, and updates primary/secondary module generation and tests accordingly. Also includes minor JS formatting/whitespace cleanups and small safety/compatibility tweaks during WebAssembly instantiation.
* Preload WASM modules and set cache headers
Inject modulepreload links into generated HTML (conditionally including wasm_bridge and bindgen when bindgen is enabled, otherwise preloading web_gl only) to improve module loading. Also change served asset Cache-Control from max-age=0 to max-age=86400 (1 day) for both brotli-compressed and uncompressed responses to enable client caching and reduce repeated fetches.
* Minify JS when copying before brotli
Add a lightweight JS minifier and apply it in cp_brotli for .js files. Introduces minify_js which strips line/block comments, collapses unnecessary whitespace, preserves strings/escaped characters and simple regex literals (heuristic), and removes empty lines. cp_brotli now attempts to read and minify .js input and write the minified output to the destination (falling back to cp on read error), then continues to optionally brotli-compress the result. This reduces payload size prior to compression with a small, simple minification step.
* Format web.js and disable XR capability checks
Apply consistent JS formatting (spacing, brace placement, object literal spacing, and minor whitespace cleanups) across platform/src/os/web/web.js. Replace the previous XR capability detection with a no-op (query_xr_capabilities now returns Promise.all([])) and remove the await call in load_deps so XR checks are not performed during startup. Also includes minor non-functional tweaks (timers, audio worklet messaging formatting, fetch call spacing, and various input/keyboard handler cleanups). Overall changes are primarily stylistic with the notable behavior change of disabling XR capability probing.
* Add WASM no-cache headers; remove web video arms
Set Cache-Control to "no-store, must-revalidate" (plus Pragma/Expires) for .wasm responses while keeping max-age=86400 for other assets; wire these into the HTTP response headers. Also remove the explicit VideoSource::InMemory and VideoSource::Filesystem match arms from the web platform code (they previously logged errors and emitted VideoDecodingError events).
166 lines
5.5 KiB
Markdown
166 lines
5.5 KiB
Markdown
# Makepad
|
|
|
|
## Socials
|
|
|
|
- Discord: https://discord.gg/adqBRq7Ece
|
|
- Rik Arends: https://twitter.com/rikarends
|
|
- Eddy Bruel: -
|
|
- Sebastian Michailidis: https://bsky.app/profile/okpokpokp.bsky.social
|
|
|
|
Makepad is an AI-accelerated application development environment for Rust. It combines a high-performance UI runtime, a live-editable design language, and a fast iteration loop so you can build native and web apps with a tight feedback cycle.
|
|
|
|
This repository contains the core engine, widgets, tools, and examples.
|
|
|
|
## What Makepad Is
|
|
|
|
- A cross-platform UI runtime for native and web targets.
|
|
- A Rust-first framework with a scriptable UI DSL.
|
|
- A studio app for running, inspecting, and iterating on examples and projects.
|
|
- An AI-accelerated workflow: structure and tooling aimed at making code generation, refactoring, and iteration faster and safer.
|
|
|
|
## Features
|
|
|
|
- Streaming Splash: fast, animated, streaming UI example.
|
|
- Script Engine: live-editable UI DSL and runtime script integration.
|
|
- 3D Rendering: glTF example with GPU rendering.
|
|
- Maps: built-in map rendering with downloadable tiles.
|
|
- Voice Analysis: built-in voice support with Whisper model downloads.
|
|
- GPU-accelerated 2D and 3D rendering.
|
|
- AI automation inside Studio to control and inspect UI.
|
|
|
|
## Prerequisites
|
|
|
|
- Rust toolchain (stable works for native).
|
|
- For non-standard targets (iOS, tvOS, Android, wasm), install the Makepad build tool:
|
|
|
|
```bash
|
|
cargo install --path=./tools/cargo_makepad
|
|
```
|
|
|
|
Then install target toolchains as needed:
|
|
|
|
```bash
|
|
cargo makepad wasm install-toolchain
|
|
cargo makepad apple ios install-toolchain
|
|
cargo makepad apple tvos install-toolchain
|
|
cargo makepad android --abi=all install-toolchain
|
|
```
|
|
|
|
## Linux Dependencies
|
|
|
|
Linux build/runtime dependencies are listed in `./tools/linux_deps.sh`:
|
|
Use the apt-get command below, or run the script on Ubuntu/WSL2:
|
|
|
|
```bash
|
|
sudo apt-get update && sudo apt-get install -y --no-install-recommends build-essential pkg-config clang ca-certificates libssl-dev libx11-dev libxcursor-dev libxkbcommon-dev libxrandr-dev libxi-dev libxinerama-dev libasound2-dev libpulse-dev libwayland-dev wayland-protocols libegl1-mesa-dev libgl1-mesa-dev libgles2-mesa-dev libglx-dev libdrm-dev libgbm-dev libgl1-mesa-dri mesa-vulkan-drivers mesa-utils mesa-utils-extra x11-apps
|
|
```
|
|
|
|
## Build And Run Makepad Studio
|
|
|
|
Makepad Studio is the main entry point for exploring examples and iterating on UI.
|
|
|
|
```bash
|
|
cargo run -p makepad-studio --release
|
|
```
|
|
|
|
If you want a local install (note: may lag the repo):
|
|
|
|
```bash
|
|
cargo install makepad-studio
|
|
```
|
|
|
|
## Examples
|
|
|
|
Run a few representative apps directly from the repo:
|
|
|
|
```bash
|
|
# Splash (simple animated demo)
|
|
cargo run -p makepad-example-splash --release
|
|
|
|
# 3D rendering (glTF)
|
|
cargo run -p makepad-example-gltf --release
|
|
|
|
# Maps
|
|
cargo run -p makepad-example-map --release
|
|
```
|
|
|
|
## Maps And Voice Assets
|
|
|
|
For built-in maps and voice support, download the assets first:
|
|
|
|
```bash
|
|
./download_map.sh
|
|
./download_voice.sh
|
|
```
|
|
|
|
## Run A WASM App
|
|
|
|
1. Install toolchain:
|
|
|
|
```bash
|
|
cargo makepad wasm install-toolchain
|
|
```
|
|
|
|
2. Run an example:
|
|
|
|
```bash
|
|
cargo makepad wasm run -p makepad-example-splash --release
|
|
```
|
|
|
|
For smaller shipped wasm output, use the shipping-size optimization pass. It keeps the post-link size reduction behavior and pairs well with the existing `small` profile:
|
|
|
|
```bash
|
|
cargo makepad wasm build -p makepad-example-splash --profile=small --strip
|
|
```
|
|
|
|
To split the wasm payloads, add `--split`. Bare `--split` uses an automatic cold-first policy: it first moves defer-safe cold functions into a secondary wasm so startup can begin on the primary first, and if there are no useful cold candidates it falls back to the normal function split. To override the function-splitting threshold directly:
|
|
|
|
```bash
|
|
cargo makepad wasm build -p makepad-example-splash --release --strip --split=200
|
|
```
|
|
|
|
For maximum size reduction, combine `--wasm-opt` (Binaryen IR optimization) and `--brotli` (compression). Install Binaryen for `--wasm-opt` (e.g. `brew install binaryen` or `apt install binaryen`):
|
|
|
|
```bash
|
|
cargo makepad wasm build -p makepad-example-splash --release --wasm-opt --strip --split --brotli
|
|
```
|
|
|
|
Notes:
|
|
|
|
- `--strip` strips custom sections (names, producers, etc.) for smaller binaries.
|
|
- `--strip-custom-sections` preserves the old behavior when you only want to remove custom sections.
|
|
- `--wasm-opt` runs Binaryen `wasm-opt -Os` for IR-level optimization (optional; requires [Binaryen](https://github.com/WebAssembly/binaryen)).
|
|
- `--brotli` compresses `.wasm` and assets with Brotli for delivery.
|
|
- `--profile=small` uses smaller fonts and pairs well with `--strip`.
|
|
- `--no-threads` trims the web thread bridge and thread exports when threading is disabled.
|
|
- The wasm linker packs relocations before the post-link size and split passes.
|
|
- `--split` emits a primary wasm plus secondary payloads (`.secondary.wasm`, `.data.bin`) and implies function splitting.
|
|
- Bare `--split` uses an automatic cold-first split policy.
|
|
- Auto mode defers the secondary when it finds defer-safe cold functions, otherwise falls back to the normal startup-path split.
|
|
- `--split=200` switches to an explicit function-body threshold (bytes).
|
|
|
|
3. Open:
|
|
|
|
```text
|
|
http://127.0.0.1:8010
|
|
```
|
|
|
|
## Run An Android App
|
|
|
|
Plug in a device with developer mode enabled, then:
|
|
|
|
1. Install toolchain:
|
|
|
|
```bash
|
|
cargo run -p cargo-makepad --release -- android --target=all toolchain-install
|
|
```
|
|
|
|
2. Run an example:
|
|
|
|
```bash
|
|
cargo run -p cargo-makepad --release -- android run -p makepad-example-ironfish
|
|
```
|
|
|
|
## Notes
|
|
|
|
- Studio uses `cargo-makepad` internally for non-standard targets.
|