Skip to content

Merge the open pull requests into main - #149

Merged
ymote merged 33 commits into
mainfrom
merge/open-prs-into-main-20261113
Nov 13, 2026
Merged

ymote merged 33 commits into
mainfrom
merge/open-prs-into-main-20261113

Conversation

@ymote

@ymote ymote commented Nov 13, 2026

Copy link
Copy Markdown

What this is

The open pull requests against main, merged together in one branch so the result could be compiled and tested before it lands. Each one comes in as its own merge commit, so merging this branch marks them merged.

Merged: #32, #90, #106, #109, #121, #122, #123, #124, #125, #126, #127, #132, #133.

Not included: #29 (draft, Android Vulkan). It rewrites the frame presentation path in platform/src/os/linux/vulkan.rs, which main has reworked since (23 later commits on the Vulkan and Android files); the conflict is in the fence wait, image acquisition and present timing. That needs a hand merge by someone who can run it on an Android device.

Conflicts resolved

One fix on top

With #125 as written, a task resumed by the new drain on isolate exit ran outside the per-entry time budget: a guest task that awaited a promise and then looped held the UI thread for good (the same script returns at once on main before the merge). Both drains now run under the isolate's own budget. Test: a_task_resumed_on_exit_is_stopped_at_the_isolates_time_budget.

Checked

  • macOS arm64: cargo check -p makepad-widgets --all-targets; makepad-widgets --lib 290 passed, 5 failed (the same 5 fail on main before the merge: two grid, one desktop_style, two widget_tree tests); the tests these pull requests add in makepad-script, makepad-script-std and makepad-widgets pass; makepad-stitch in release 97 + 18 passed (its spec suite overflows the stack in a debug build on main too).
  • OpenHarmony: cargo check -p makepad-platform --target aarch64-unknown-linux-ohos with the DevEco NDK.

Not checked

🤖 Generated with Claude Code

ymote and others added 30 commits October 1, 2026 09:05
Every Back (key, navigation button, system edge gesture) now goes through
one MakepadActivity.dispatchBackPressed(): an open QR scanner closes, the
application extension may consume it, otherwise MakepadNative.onBackPressed.
super.onBackPressed() no longer finishes or backgrounds the activity before
the widget tree has handled the event.

The surface leaves KEYCODE_BACK unhandled instead of forwarding it to Rust
as KeyDown(Back) (which became a second BackPressed). Below API 33 the
activity's onKeyUp -> onBackPressed delivers it; on API 33+ an
OnBackInvokedCallback (PRIORITY_DEFAULT, so the IME's Back stays first) does,
and cargo-makepad's manifests opt every activity in with
android:enableOnBackInvokedCallback.

ApplicationExtension.usesSystemBackCallback() lets an extension that owns its
own system callback keep it: the activity then registers none and drops the
compatibility Back key. This upstreams OctoSense's
tools/runtime-patches/makepad-system-back.patch with the same interface.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Makepad on a HarmonyOS 2-in-1 (MateBook Pro, HarmonyOS 7.0, API 26) took
no mouse, trackpad or hardware-key input and had no system browser. This
moves the OpenHarmony glue from ArkTS to the NDK wherever the NDK has an
API, and adds what was missing:

- Input: XComponent mouse events (press, release, move, hover) as
  MouseDown/Move/Up; touches synthesized from a mouse are dropped. Hardware
  keys as KeyDown/KeyUp (XComponent key callback, modifiers from API 20).
  Wheel and two-finger touchpad scrolling as Scroll (the node's
  NODE_ON_AXIS), at the last mouse position.
- Input method through libohinputmethod (oh_ime.rs) instead of ArkTS
  @ohos.inputMethod: text, delete back/forward, Enter (a function key),
  cursor moves and cut/copy/paste become text and key events; attach, show
  and hide run in order on the main thread, attached with the node's UI
  context. A press that arrives both as a key and as an input-method
  message counts once.
- The XComponent is created natively (node_shim.cpp, ArkUI node API) in a
  NodeContent the page hands over: Index.ets is one ContentSlot. Messages
  arriving before the surface are kept for after it.
- Device type, OS name and display density from the NDK (oh_env.rs); the
  module's directories still come from ArkTS (the NDK only reports the
  application's, a different place).
- System browsers (cx.system_browser) with ArkWeb (oh_web.rs,
  web_shim.cpp): the NDK has no web node, so the page declares one Web per
  browser above the ContentSlot; the page bridge
  window.octos_native.invoke(callId, tool, args) is a native
  registerJavaScriptProxy and eval_js a native runJavaScript. Loads and
  history are controller calls ArkTS runs from a queue, after the first
  blank page (an earlier load is aborted); navigation, errors and the
  navigation policy are forwarded Web events. A spawn() browser may follow
  a redirect to another host of the same site: ArkWeb on a 2-in-1 presents
  a desktop browser and m.youtube.com redirects to www.youtube.com.
- System fonts: /system/fonts on OpenHarmony and Android.

The shims are C++ against the SDK headers (the APIs are function-pointer
tables), compiled by platform/build.rs with cargo-makepad's
CXX_/AR_<target>, no C++ runtime (-fno-threadsafe-statics).

Checked: cargo check for aarch64-unknown-linux-ohos and the host; run on
the MateBook Pro inside OctoSense's desktop build: clicks, typing, Enter,
Ctrl+C, trackpad scrolling and a YouTube video in a system browser.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e stack

call_host and the host branch of call_indirect got the trampoline's
Result<StackGuard, Error> back through a stack slot in the handler's own
frame. That slot's address escapes into the call, so LLVM could not turn
the handler's final call to the next instruction into a sibling call, and
every host call left a frame behind, roughly 150-200 bytes each (Apple
M5 Max). A module that calls a host function in a loop overflowed an
8 MiB thread after 40,000-60,000 calls and aborted the process; calls
between wasm functions were not affected.

The host call now happens in an out-of-line helper, so the slot lives in
the helper's frame. A million host calls run on a 1 MiB stack, and a host
call is faster: about 22 ns before, 10 ns after, in a release build.

tests/host_calls.rs loops a million direct and indirect host calls on a
1 MiB thread. Without the fix both abort with a stack overflow, in debug
and release builds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…dget

The budget is wall-clock time, so it counts time an entry spends waiting
for the CPU or a lock, not just the script. A test binary running ~1,000
tests in one process is where that breaks down. On a two-socket 72-vCPU
Linux host, OctoSense's shell suite at 18-72 test threads turns a 6 ms
Photos entry into 65-1,100 ms. Two causes were measured:

- The process-wide LiveId interner mutex, which the tokenizer takes
  ~12,700 times per entry: 90-230 ms of lock waits under load, mostly
  futex time in the kernel.
- Page faults stalled behind other threads' memory-map changes.

Tests then fail with "script time budget exceeded" while asserting
behaviour that has nothing to do with time.

The variable is read once. An unset, empty, zero or unparsable value keeps
64 ms, so nothing changes unless a process opts in.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
load_file_direct() only opens the resource's recorded, build-machine path.
When that path does not exist -- a copy of a build on another machine --
every resource of the crate is missing at once and the view is drawn
without its icons.

Fall back to dependency_path under <exe dir>/resources/, the same location
a packaged build already resolves. Reached only when the recorded path
yields nothing, so a normal checkout is unaffected.
…path

get_resource_font_bytes_by_path() tries the resource's recorded,
build-machine path first. On a machine that did not build the binary that
path does not exist and the font is not read: the family renders without
its member and text is laid out with no glyphs.

Try dependency_path under <exe dir>/resources/ as well -- the same
location and name a packaged build resolves. A strict fallback.
…r gate

App Flow #9, under ADR 0001. A completion provider needs a data source
that cannot be wrong about whether a name exists, and this crate is
where that source lives: the query is about the VM's own objects, and a
host that is not an editor has the same question.

Two functions, and the count is the decision (ADR 0001 §1):

  * query::object_keys(heap, object) -> Vec<String> — the object's own
    entries, each name once, sorted, without values. The prototype chain
    is deliberately not walked: whether a shadowed name appears once or
    twice, and whether a native type's getter table counts as a key, is
    policy, and policy belongs to the one consumer with a use for it.
  * query::module_object(heap, name) -> Option<ScriptObject> — a module
    object by dotted name, rooted at the module table (`mod` is the
    table's own name, the way the global is). A name the VM does not
    have is None; neither function traps, runs script or mutates.

Both are reads an editor performs per keystroke, so neither inherits
the default type getter's trap — the one place a language server must
not produce an error is the path it takes while the person is typing.

The stability promise (ADR 0001 §4) is kept by hand, because this fork
has no CI and makepad-script is not on crates.io:

  * tests/query_api_surface.rs binds the two signatures to consts, so a
    removal, rename or reshape stops the build, and a checked-in surface
    file must keep describing the API — a breaking change cannot land
    without the diff being named in the pull request.
  * tests/query_corpus.txt is the fixture corpus: the modules a real
    isolate installs and the key sets each must answer, with a runner
    per crate that installs them (script-tagged entries run with
    `cargo test -p makepad-script`, widgets-tagged ones with
    `cargo test -p makepad-widgets` — one corpus, one review artifact).
    Regenerate with QUERY_CORPUS_WRITE=1 and read the diff.

The corpus records each object's total entry count beside its key set,
because a name is not always recoverable: a key registered in Rust with
id! and never spelled by source is an id the VM cannot turn back into a
string — the same gap its own "Did you mean" lists have — and
object_keys does not invent one. Five such entries exist in
mod.prelude.widgets (SAFE_INSET_PAD_* and friends); recording the total
keeps them a visible diff rather than a silent shrink.

The chain-walk test (ADR 0001 §2's fourth criterion) proves the walk
that was left out is safe to leave out: heap.proto and
proto_map_iter_mut_with reach every inherited name from outside.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The script-side constructor already accepts ignore_ssl_cert and the flag
reaches the network backend as written (verified end-to-end against a
self-signed loopback HTTPS endpoint from card-host: status 200 with the
flag, TLS refusal without). OctoSense-org/OctoSense#490 mis-reported the
field as unexposed; this test pins the round-trip so the question never
needs re-asking, and the field gains a doc comment marking it
loopback/dev-only (the per-isolate host allowlist still applies).
A Splash isolate's script has no event-dispatch beat of its own: the
main VM drains its promise/task queues after every call_event_handler,
but an isolate's queues were only ever drained when some unrelated
event happened to enter it. So a promise resolved by a timer callback
or a network response never resumed its awaiting task while the app
was idle — repro with a one-button app whose on_click awaits a
start_timeout promise: the label stays 'waiting' forever unless the
user keeps clicking (OctoSense-org/OctoSense-App-Hub#213).

Both isolate entry paths now pump on the success branch:
with_isolate_installed (script-call entries: timer dispatch, network
delivery, call_script_fn) and with_isolate (host draw/dispatch
entries). The pump is the same makepad_script_std::pump the main VM's
signal tick runs; a panicking entry skips it (the thread list may be
mid-teardown and the host tears the isolate down anyway), and nested
entries skip it (the outermost one drains).

Pinned by a_resolution_queued_during_an_isolate_entry_resumes_on_exit,
which fails without the pump, and verified live on Wayland with
card-host: both the timer-promise probe and an HTTPS fetch's
on_response now deliver with the event loop completely idle (no user
input nudges).
…ad#492)

An arm whose tail produces no value — for/while (FOR_END), let,
break/continue, an empty body, or a `;` tail whose commit already ran
inside the arm — handed the join nothing, while the statement-end
set_pop_to_me that follows the construct places a pop on the join (a
standalone POP_TO_ME at the jump target) or just past it. The pop then
read through the base of the stack: the next call in the same body
trapped with `pop_stack_value on empty stack`, and when the body was an
`on_render` handler the whole output was discarded silently. In
expression position (`let x = if …`) the same shape dropped the binding
("variable x not found").

close_branch() now stands in a NIL for value-less arms of if/elif/else
and of match arms; the try protected/catch block closes do the same
while leaving the canonical-catch marker rewrite untouched (a `;` tail
keeps its fused commit for that path).

Fixes OctoSense-org/OctoSense#492.

Tests: platform/script/tests/if_for_else_stack.rs covers the issue's
exact shape plus the value-less-tail family across if/try/match/elif
and expression contexts. All makepad-script suites stay green.
WM_ACTIVATE delivers WA_INACTIVE (0), WA_ACTIVE (1) or WA_CLICKACTIVE (2) in
the low word of wparam. Only WA_ACTIVE was recognised as activation, so a
window activated by a mouse click was reported as WindowLostFocus instead of
WindowGotFocus. With two Makepad windows open, clicking the inactive one
cleared its focus state on every click and its buttons stopped responding;
with a single window no activation change occurs and the bug never shows.

Verified by cargo check -p makepad-platform --target x86_64-pc-windows-msvc.
… primary beat

The beat wait (MsgWaitForMultipleObjectsEx) returns the lowest signaled handle,
and the primary window is index 0. While the primary keeps presenting, for
example a blinking caret in a text input, its waitable is signaled on every
pass and the wait never returns a secondary window. During the primary beat a
secondary window with a dirty pass is held back "for its own beat", so its
frame never reaches the screen until the primary falls silent, the window is
resized (unpaced present) or the primary is minimized (its waitable goes quiet).

Observed in Hagency Desktop: with the main window behind it, clicks in the
Mini apps window took effect but nothing repainted; minimizing the main window
or resizing the Mini apps window made the result appear.

During another window's beat, probe the held-back window's own clock with a
zero-timeout wait (or its already-held credit). If the compositor is ready for
it, paint it in this tick; the present spends the credit the probe took.

Verified by cargo check -p makepad-platform --target x86_64-pc-windows-msvc.
The "sysv64" ABI exists only on x86-64, so stitch fails to compile on
aarch64-pc-windows-msvc with E0570. AArch64 passes enough arguments in
registers under the C ABI, so only x86-64 Windows needs the override.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Conflict in widgets/src/widget_async.rs: main and the pull request each
added a test at the same place; both are kept.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
ymote and others added 3 commits November 12, 2026 22:02
Conflict in widgets/src/widget_async.rs: main has since given every isolate
its own time budget, set by its host. That stays. The pull request's
MAKEPAD_SPLASH_BUDGET_MS now sets the budget an isolate starts with, in
place of the fixed 64 ms; a host's own budget still takes its place.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Conflicts with the OpenHarmony work main has had since:

- wait_init keeps main's loop that skips what arrives before Init; the Init
  arm gains the pull request's platform data directory and input-method
  start.
- wait_surface_created waits for the surface itself, as on main, and keeps
  what arrives first for after the surface exists, as in the pull request;
  each kept message is named in the startup log.
- ShowTextIME and HideTextIME use the pull request's native input method,
  shown once per configuration as on main.
- Both sides' additions at the end of open_harmony.rs are kept, and the
  startup log names the pull request's new message kinds.
- makepad.ets is the pull request's version with main's later keyboard
  height fix (a height of 0 is reported); the ArkTS keyboard functions and
  XComponentAttrs, unused after the pull request, are gone.

Checked: cargo check -p makepad-platform for aarch64-unknown-linux-ohos.
Not built or run on a device.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… budget

The drain added for OctoSense-App-Hub#213 resumes guest tasks after an entry
into a Splash isolate, outside the per-entry time budget. A task that was
woken and then never yielded (await a promise, then loop) held the UI thread
for good: the entry that resolved the promise did not return.

A resumed task is guest script like any other entry, so both drains (script
call entries and host draw/dispatch entries) now run under the isolate's own
budget. The budget is put back whether or not the drain unwinds.

Test: a_task_resumed_on_exit_is_stopped_at_the_isolates_time_budget (without
the change it does not return).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@ymote
ymote merged commit 9091aa8 into main Nov 13, 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.

8 participants