Commit graph

169 commits

Author SHA1 Message Date
Admin
91f0873847 vulkan video textures 2026-03-17 19:00:28 +01:00
Admin
a8f5877687 quite good 2026-03-17 19:00:28 +01:00
Admin
c3ad851992 almost reasonable 2026-03-17 19:00:27 +01:00
Admin
6658d6515f slow voxels 2026-03-15 15:36:30 +01:00
Admin
64b1a7c74b vulkan back 2026-03-15 13:20:49 +01:00
Sabin Regmi
51f23402b5
Expose WEB URL and Location Handling (#941)
* Add web URL/location and history handling

Sync browser location and history with the WASM app on the Web platform.

- Cx API: add default CxOsApi methods browser_update_url and browser_history_go and Cx wrappers to call them.
- Web/WASM IPC: add ToWasmLocationChange, FromWasmBrowserUpdateUrl, FromWasmBrowserHistoryGo structs for message passing and register them in init.
- Web JS: emit_location_change on popstate, and implement FromWasmBrowserUpdateUrl and FromWasmBrowserHistoryGo to update history (push/replace/back/forward/go).
- Cx web runtime: add normalize_web_pathname, split_web_location and update_web_location_state helpers; handle incoming ToWasmLocationChange to update internal state and signal events; implement browser_update_url and browser_history_go to forward requests to JS and update internal location state.

These changes enable SPA-style URL updates, history navigation, and app-side reactions to browser location changes while avoiding redundant updates.

* Handle hashchange and improve URL parsing

Add a window "hashchange" listener to emit location changes and trigger the wasm pump so fragment navigation updates are handled. Update FromWasmBrowserUpdateUrl to construct URLs relative to the current full location (window.location.href) so fragment- and relative-only updates resolve correctly. Tighten split_web_location parsing to treat '/', '?', and '#' as path delimiters after a scheme, ensuring queries and fragments are detected when extracting the path.

* fix wasm run without --release

* LTO off in small profile
2026-03-14 12:13:28 +01:00
Admin
bca911513d xr otw 2026-03-12 15:51:30 +01:00
Admin
cde02e2e48 fix 2026-03-11 18:15:12 +01:00
Admin
5170eed9af working 2026-03-11 10:19:58 +01:00
Sabin Regmi
ffbeadc173
Hotreloading Nits (#936)
* Add wasm server_manager and ownership guard

Introduce a new wasm server_manager module that implements WasmServerOwnershipGuard to manage per-workspace lock files, PID/port ownership, and safe replacement of stale or live servers. Integrate the guard into compile::run by preparing and activating the guard before starting the HTTP server; start_wasm_server now accepts the guard, returns a Result, checks bind success, activates the guard, and propagates thread join errors. The server manager includes platform-specific PID handling, port-probing, lock read/write/remove helpers, and unit tests exercising startup scenarios and lock lifecycle. Also add mod declaration and apply minor formatting/refactor cleanups across compile.rs (error formatting, whitespace, and logging improvements).

* Add startup mutex and port occupant diagnostics

Rename server_manager into top-level module and add startup mutex handling and improved diagnostics. Introduces atomic lock writes (write_file_atomically), a StartupMutexGuard with configurable timeouts/polling, and logic to detect/recover stale startup locks to prevent concurrent wasm run startups. Extends ServerManagerProbes with describe_port_occupant and implements platform-specific detection (lsof on Unix, netstat/tasklist on Windows) to provide clearer errors when ports are occupied. Updates imports (main.rs, compile.rs, mod.rs) and adds unit tests covering startup lock behavior and unknown-occupant error text.

* Improve hot-reload logging and delivery

Add clearer logging and error handling for wasm hot-reload events. Introduces hot_reload_display_name to extract a user-friendly file name, logs when a hotreload is detected, and checks tx.send result to avoid panics when the watcher channel is closed. broadcast_hot_reload_event now logs whether events were skipped (no /$watch clients) or sent and includes the delivered client count with proper pluralization.

* Check lock PID owns port and add startup timestamp

Require that a lock's PID both be alive and actually own the server port to be considered a live lock (classify_lock_state now takes listen_addr). Add parsing of a started_at timestamp in startup locks and use now_unix_millis to age out stale startup locks even if the PID is alive. Extend ServerManagerProbes with now_unix_millis and pid_owns_port, implement port_occupant_info and PortOccupant to centralize occupant detection/refinement for unix and windows, and refactor describe_port_occupant to use it. Update tests and MockProbes to exercise PID ownership checks and startup-lock aging; add tests for PID reuse (treated as stale if it doesn't own the port) and for startup lock aging.

* Hot reload: dedupe sites, add logging

Avoid duplicate ScriptMod sites during hot reload and improve diagnostics. collect_compiled_sites_for_file now tracks seen ScriptModKey values to prevent pushing duplicates. handle_cx_live_edit counts processed files and logs how many overrides were applied and from how many changed files. forward_hot_reload_fs_event logs each detected file and reports if the watcher channel is closed. Minor import cleanup and a helper hot_reload_display_name were added for nicer log output.

* shared core for reload

* Warn and fallback to unminified JS on write error

When writing the minified JS file fails, log a warning and fall back to copying the original JS file instead of returning an error. This avoids failing the build on IO/write errors (e.g. permissions or disk issues) while preserving the previous behavior of using the unminified copy when reading fails. No change to successful minification path.
2026-03-10 12:47:38 +01:00
Admin
39d107a09b wasm hotloading 2026-03-09 19:26:08 +01:00
Sabin Regmi
9cf8128f15
WASM Binary Optimization + Splitting (#925)
* 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).
2026-03-09 18:52:49 +01:00
Admin
bdf760b58b wasm media 2026-03-09 18:00:25 +01:00
Admin
7a9274ebf8 wasm media 2026-03-09 17:43:54 +01:00
offline-ant
7c7d91b8ad
platform: video/camera subsystem with media plugin architecture (#929)
Video playback: extended API with volume, playback rate, seek ranges,
buffered ranges, can_play_type, audio-only mode. Unified player wrapping
native backend (AVPlayer/GStreamer/MediaFoundation) with software fallback.
YUV shader pipeline (BT.601/709/2020, NV12 biplanar, rotation).

Camera: V4L2 backend (Linux), expanded NDK Camera2 (Android), AVCapture
stream refactor (iOS/macOS) with shared session architecture. NV12
zero-copy paths on iOS (CVMetalTextureCache) and Android (AImage planes).
Camera preview modes (texture/native/auto).

Video encoding: H264 hardware encode on Apple (VideoToolbox) and Android
(MediaCodec). Camera-to-encoder pipeline with pixel buffer passthrough.

Media plugin system: externalized codec implementation via MediaPlugin
trait. MsePlayer, VideoFrameDecoder, MediaVideoEncoder, SoftwareVideoPlayer
interfaces. Runtime codec capability query and merge.

Includes camera example app.

Co-authored-by: ant <ant@offline.click>
2026-03-08 13:10:58 +01:00
offline-ant
814fe4d9cd
platform: native mobile selection handles (#930)
* platform: popup window API with X11/Wayland support

- Add popup window type for context menus and dropdowns
- Wayland: xdg_popup with grab for compositor-driven dismiss
- X11: override-redirect windows with pointer grab
- Explicit-close semantics: app must handle PopupDismissed
- Fix Wayland crash on repeated context menu open/close
- Emit WindowClosed before PopupDismissed in PopupDone

* platform: native mobile selection handles

iOS: custom UIView selection handles with UIPanGestureRecognizer (all versions),
UITextSelectionDisplayInteraction for native highlights (iOS 16+),
MakepadSelectionRect for UITextInput protocol.

Android: custom SelectionHandleView with GradientDrawable oval, touch drag
listeners, JNI bridge for handle drag events.

Widgets: TextFlow clipboard action integration (show on touch up with selection,
hide on touch down/focus lost, TextCut handler), PortalList select-all and
clipboard actions, selection bounding rect computation for popup positioning.

Includes text_selection example app.

---------

Co-authored-by: ant <ant@offline.click>
2026-03-08 12:15:31 +01:00
offline-ant
04dea089bd
platform: small fixes and quality improvements (#928)
- Android log levels: map log! macro levels to Android log priorities
  (ERROR=6, WARN=5, INFO=4). Some devices suppress DEBUG by default.
- cargo-makepad android: show help text instead of panicking on missing
  or invalid subcommand.
- Android build: discover .class files dynamically instead of hardcoding
  ~25 individual paths. Add Java 8 source/target flags.
- Remove deprecated AsyncTask import from MakepadNetwork.java.
- Studio stdout: add newline after JSON messages for JSON-lines parsing.
- Studio stdout: skip profiler timing in stdout mode to avoid overhead.
- Script thread: fix panic on empty call stack in call_has_me/call_has_try.
- Cursor: reset to Default on FingerHoverOut in TextFlow and TextInput.

Co-authored-by: ant <ant@offline.click>
2026-03-08 11:24:18 +01:00
Admin
24a9b0627d remove apprs 2026-03-08 10:28:40 +01:00
Sabin Regmi
713628a89f
Load script resources per-handle (avoid global loads) (#923)
Replace broad cx.load_all_script_resources() calls with a targeted cx.load_script_resource(handle) to only request the specific resource needed. Refactor script resource loading (platform/src/script/res.rs) by extracting load_script_resource_impl(handle, crate_manifests) and exposing load_script_resource(handle); keep load_all_script_resources() by iterating per-handle. Improve wasm handling: resolve web_url per-resource, set explicit error states when missing, and fire async HTTP requests safely. Remove an early call to load_all_script_resources() from web startup. Additional changes: serve precompressed .br files in the local wasm dev server (with COOP/COEP headers when threaded), add wasm-specific font/theme script entries for widgets, and update various callers (draw shaders, widgets, math_view, gltf/view_splat, image) to use the per-handle loader. These changes reduce unnecessary global loads and limit network/file operations to only required resources.
2026-03-06 16:01:07 +01:00
offline-ant
d19f99d1ef
selection: clipboard delegate, primary selection, mobile handles (#912)
* selection: clipboard delegate, primary selection, mobile UI, handles, accessibility

Level 0: Route clipboard through Makepad instead of arboard. Custom
ClipboardDelegate in havishell forwards set_text/get_text/clear through
Makepad's CopyToClipboard and pending paste state. Fix Wayland serial
constraint by queuing CopyToClipboard when no serial is available.

Level 1: Primary selection (Linux). Add CxOsOp::SetPrimarySelection,
Wayland zwp_primary_selection_device_manager_v1 protocol bindings, X11
PRIMARY atom handling. HAVI stores selection text in SharedDocumentSelection
and calls set_primary_selection on change.

Level 2: Mobile clipboard actions UI. Long-press selects word and shows
native clipboard toolbar. TextCopy/TextCut events return selection text.

Level 3: Selection handle API. Add CxOsOp Show/Update/HideSelectionHandles,
Event::SelectionHandleDrag, and HAVI integration for handle drag events.
Platform stubs for all backends.

Level 4: Accessibility plumbing. Add CxOsOp::AccessibilityUpdate with
type-erased Box<dyn Any + Send> payload. HAVI implements
notify_accessibility_tree_update to forward accesskit::TreeUpdate through
Makepad. Platform no-op stubs.

* wayland: handle primary selection data_offer child objects

---------

Co-authored-by: ant <ant@offline.click>
2026-03-06 12:17:25 +01:00
Admin
1924bc2f6b cleanup 2026-03-05 23:45:21 +01:00
Admin
c9bd068a70 parity! 2026-03-05 23:45:21 +01:00
Admin
4207f0d4e9 nearly there 2026-03-05 23:45:21 +01:00
Admin
3b0f5a5c40 almost 2026-03-05 23:45:21 +01:00
Admin
394ee17864 shadows 2026-03-05 23:45:21 +01:00
Admin
8c3f839ee3 base correct 2026-03-05 23:45:21 +01:00
Admin
8ee09a8466 improving.. 2026-03-05 23:45:21 +01:00
Admin
00ce91ab5e right direction 2026-03-05 23:45:21 +01:00
Admin
7f313a6261 mb3d experiment 2026-03-05 23:45:21 +01:00
Sabin Regmi
8e3ae8ea1c
Add --no-threads option and runtime thread checks (#918)
Introduce a single-threaded wasm build mode and add defensive runtime handling for missing wasm threading support.

- CLI: add --no-threads flag and WasmConfig.threads to control threaded vs single-threaded builds. Parse and strip wasm-specific options before forwarding build/run args.
- Build: select target features and RUSTFLAGS based on threading; omit atomics/bulk-memory features for single-threaded builds. Adjust generated server instructions to require COOP/COEP only for threaded builds.
- Dev server: conditionally include COOP/COEP headers when serving threaded wasm artifacts.
- JS runtime (platform/src/os/web/web.js): guard audio worklet startup and thread creation on wasm._has_thread_support; make alloc_thread_stack return null with clear console warnings when required exports or alignment are missing; pass allocated thread_info to workers.

These changes enable building and running a single-threaded wasm variant without COOP/COEP server requirements and improve runtime resilience when threading features are unavailable.
2026-03-05 20:53:20 +01:00
Admin
4a87f4ca31 fix scrolling 2026-03-04 09:16:48 +01:00
Admin
c0125ba11d widget tree fixup 2026-03-03 20:19:06 +01:00
Admin
cb92b61b66 terminal otw 2026-03-03 17:47:24 +01:00
Admin
81483d4555 y flip webgl rendertartet 2026-03-03 09:42:54 +01:00
Admin
0f3864a44a rename network 2026-03-03 09:18:19 +01:00
Admin
5d6472c2a0 add studio proto 2026-03-02 12:30:33 +01:00
Admin
b437899d82 remote control 2026-03-02 12:07:59 +01:00
Admin
462fd3dcec remote working 2026-03-02 10:40:33 +01:00
Admin
2b06c8846a filter proto 2026-03-02 09:32:23 +01:00
Admin
1ef52d6553 wasm 2026-03-01 20:22:11 +01:00
Admin
01a4985e86 backend proto splitoff 2026-03-01 10:12:00 +01:00
offline-ant
0ce6ec05e8
Apple metal and compile updates (#903)
Merge actool partial Info.plist into main plist for iOS 15 icon support.

Co-authored-by: ant <ant@offline.click>
2026-02-28 11:36:48 +01:00
offline-ant
f0907d6782
Fix missing app icons on iOS 15 by adding classic idiom entries to asset catalog (#902)
The Contents.json only had a single universal+platform entry, which is
only recognized by iOS 16+. Add classic per-idiom entries (iphone, ipad,
ios-marketing) so actool compiles both sets into Assets.car. iOS 15
falls back to the idiom-based entries.

Co-authored-by: ant <ant@offline.click>
2026-02-28 11:16:59 +01:00
offline-ant
e1d3653de2
iOS: app icons, fullscreen, iOS 15 support, GL texture fix, NSLog logging (#897)
Co-authored-by: ant <ant@offline.click>
2026-02-27 16:42:47 +01:00
offline-ant
fdc918a890
iOS: GL render bridge (EAGL+IOSurface) and ios build command (#894)
* iOS: add GL render bridge (EAGL+IOSurface), fix linking, fix warnings

- Add EaglRenderBridge for iOS (GLES 3.0 context sharing textures with
  Metal via IOSurface), mirroring macOS CglRenderBridge
- Add iOS GlRenderBridge inner field and Cx methods
  (create_gl_render_bridge, create_gl_render_bridge_texture, restore_gl_context)
- Widen IOSurface support from macos-only to macos/ios/tvos in apple_sys
  and metal.rs (CxOsTexture fields, update_shared_texture, etc.)
- Expose metal_device() accessor on IosApp
- Replace removed SSLSetEnableCertVerify with SSLSetSessionOption
  (kSSLSessionOptionBreakOnServerAuth) to fix iOS linker error
- Remove unused apple_util::* imports in ios.rs and ios_app.rs
- Fix iOS deployment target from 26.0 to 17.0 in cargo_makepad

* cargo-makepad: add apple ios build command, expose IosBuildResult fields

---------

Co-authored-by: ant <ant@offline.click>
2026-02-27 08:40:41 +01:00
offline-ant
f71bdf48f7
android: add launch splash themes to cargo-makepad manifests (#895)
Co-authored-by: ant <ant@offline.click>
2026-02-27 08:40:26 +01:00
offline-ant
4f34bce7ee
cargo-makepad: isolate android/apple target dirs from desktop builds (#896)
Android defaults to target/android/, apple to target/apple/.
Prevents cross-platform builds from invalidating each other's caches.

Co-authored-by: ant <ant@offline.click>
2026-02-27 08:40:14 +01:00
offline-ant
b3cec2dd2d
cargo-makepad android: use crate name for Rust .so lookup (#893)
Co-authored-by: ant <ant@offline.click>
2026-02-26 20:00:04 +01:00
offline-ant
31f2a41038
cargo-makepad: cross-platform icon build pipeline and desktop packaging (#890)
Refactor app icon handling into a unified app_icon module that replaces
the old window_icon.rs. Build-time icon generation produces platform-
native formats (ICO with multiple sizes for Windows, ICNS for macOS,
multi-resolution PNGs for Linux/Wayland/X11).

Add `cargo makepad desktop` subcommand for desktop packaging with
automatic icon detection from MAKEPAD_APP_ICON_PATH env var, or from
Cargo package metadata.

Resolve binary names from [[bin]] targets in Cargo.toml so .app bundles,
.exe outputs, and APK labels use the correct name instead of defaulting
to the package name.

Use llvm-rc for Windows .res generation (cross-compilation compatible)
with absolute link paths for reliable resource embedding.

Co-authored-by: ant <ant@offline.click>
2026-02-26 11:33:26 +01:00
Admin
8b42b20198 restore merge script 2026-02-26 10:09:28 +01:00