Skip to content

Fix native platform review findings (clocks, store validation, Vulkan, resources) - #401

Merged
tiensonqin merged 13 commits into
mainfrom
logseq/native-review-fixes-ac02
Nov 20, 2026
Merged

tiensonqin merged 13 commits into
mainfrom
logseq/native-review-fixes-ac02

Conversation

@tiensonqin

@tiensonqin tiensonqin commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes review findings against platform/native at 87fcf6af. Host loops now tick application and animation clocks, the retained store rejects invalid structural batches atomically, Linux Vulkan uploads only damaged rows and resizes the frame image without rebuilding the device, and resource/PTY/DBus paths stop dropping work or blocking the runtime.

Review follow-up (9f2cba78): Vulkan damage is invalidated after blit resize; blit resize errors are logged without dropping the cell; Linux/Windows clocks are sampled after event drain; macOS wait preserves Frame.Wait_ms; Windows idle Sleep is capped at 4ms; D-Bus watch uses C select on raw fds (no %identity); GTK still gets a 50ms GLib wake; resource spawn failures notify watchers; terminal pending writes use a two-list queue.

Findings

High

  • H1 fixed. Hosts call Lui_app.tick_clock every iteration and fold Lui_clock.next_delay via Lui_window.fold_wait_ms. Toast duration is applied by Ui.store_changed; demo toast_since workarounds are gone.
  • H2 fixed. RemoveChild only adds a child to roots when a link was actually cut.
  • H3 partially fixed. Damaged-row upload + Lui_vulkan.resize keeps instance/device/pipelines. Swapchain present deferred (host still readback+blit).

Medium

  • M1 fixed. apply_batch validates against a structural shadow (cycles, wrong-parent RemoveChild, missing nodes) and fails the batch with op context so the host can resync. InsertChild/MoveChild with an unknown parent (gallery parent=-1) remains a no-op. Property ops on missing ids stay ignored.
  • M2 fixed. Hosts call Lui_host.tick ~now every frame; wants_repaint already requests redraws while animations run.
  • M3 fixed. Default resource executor is a bounded domain pool; spawn failures mark Failed and notify watchers; hosts drain_all and set_completion_wake via SDL; terminal plugin tables are mutex-protected.
  • M4 fixed. Linux watches D-Bus unix fds via C select and wakes SDL. GTK/AppIndicator still uses a 50ms cap because GLib sources are not those fds.
  • M5 fixed. Terminal pump retries the unwritten tail of nonblocking PTY writes.
  • M6 fixed. Blocking dbus_connection_send_with_reply_and_block releases the OCaml runtime.

Low

  • L1 fixed. Renderer error/noop frames use Bytes.make ... '\000'.
  • L2 fixed. Shader fallback uses mkdtemp, cleans up on all paths, releases the runtime around fork/wait.
  • L3 fixed. PTY master FD_CLOEXEC, spawn OOM frees argv/env/record, close is idempotent. Unix still ignores env (documented, unchanged).
  • L4 fixed. Pango pkg-config rules fail instead of swallowing errors.
  • L5 fixed. Linux blit resize errors are logged; the cell is kept so a later resize can retry.

Tests

  • Store: stale RemoveChild (apply_op + batch), cyclic insert, missing-node structural ops, missing-parent insert no-op, wide removal complexity.
  • Window: fold_wait_ms, toast duration dismiss, idle allocations.
  • Vulkan: changed_rows, resize keeps device.
  • Resource: spawn-raise marks Failed and notifies watchers, bounded pool + completion wake.
  • Terminal: flush_pending, close twice.
  • Linux: dbus wait cap (including GTK), zeroed noop frame.
  • Layout incremental random uses the leaf ids it actually created.

Build

dune build platform/native/   # success
dune runtest platform/native/ # success (`--force`, exit 0)

Swapchain present for Linux Vulkan is the remaining H3 follow-up. A full GLib fd integration for idle tray actions is the remaining M4 follow-up when GTK is up.

Open in Web Open in Cursor 

Devin Review

cursoragent and others added 11 commits November 20, 2026 20:32
A RemoveChild named against the wrong parent left the child in its
real parent's list but still added it to the forest roots, so
preorder visited it twice. Only promote to roots when a link was
actually cut.

Co-authored-by: Tienson Qin <tiensonqin@gmail.com>
Cyclic inserts, stale RemoveChild, and structural ops on missing nodes
now fail the whole batch with op context, leaving the tree unchanged.
Lui_host.apply_batch returns false so the runtime can resync, matching
Web and Android. Property writes to missing ids stay ignored.

Co-authored-by: Tienson Qin <tiensonqin@gmail.com>
Shadow child sets replace per-op list filters so wide RemoveChild
batches stay O(n). InsertChild/MoveChild whose parent is not a node
(including gallery parent=-1) is a no-op, matching apply_op. The
incremental layout random test now mutates the leaf ids it created.

Co-authored-by: Tienson Qin <tiensonqin@gmail.com>
Lui_window.fold_wait_ms combines the UI input deadline, Lui_clock.next_delay,
and an optional host-wants-frame wake. Toast nodes with a duration prop
schedule Dismiss from store_changed and wake next_input_deadline, replacing
the demo toast_since workaround. Idle store_changed stays allocation-quiet
when no toasts are live.

Co-authored-by: Tienson Qin <tiensonqin@gmail.com>
Lui_vulkan.resize rebuilds the offscreen image and framebuffer while
keeping the instance, device and pipelines. changed_rows lets the Linux
host upload a dirty row span instead of the whole readback. Shader
fallback compile uses a private mkdtemp directory, cleans up on every
path, and releases the OCaml runtime around fork/wait. Window swapchain
present remains a follow-up.

Co-authored-by: Tienson Qin <tiensonqin@gmail.com>
Lui_resource.create defaults to a small Domain pool instead of one
spawn per load. request/reload mark the entry Failed when the executor
raises, so a domain-cap error cannot leave it stuck Loading. Completions
call an optional set_completion_wake so hosts can unblock an idle wait.
Hosts that drain every frame land in a later commit.

Co-authored-by: Tienson Qin <tiensonqin@gmail.com>
The Unix master fd gets FD_CLOEXEC. The spawn OOM path frees argv, env
and the pty record before failing. OCaml close zeros the handle before
c_close, and the stub clears mfd so a second close does not double-free.

Co-authored-by: Tienson Qin <tiensonqin@gmail.com>
pump keeps the unwritten tail of nonblocking writes instead of dropping
it. pending is oldest-first. Service tables (terms/next) are mutex
protected because resource workers can complete off the main domain.

Co-authored-by: Tienson Qin <tiensonqin@gmail.com>
Shell and a11y expose unix_fd so the Linux wait loop can select instead
of capping idle at 50ms. dbus_wait_cap_ms keeps the cap only when the
bus is connected but no fd is available. Blocking send_with_reply_and_block
releases the OCaml runtime. Noop renderer frames are zeroed with
Bytes.make.

Co-authored-by: Tienson Qin <tiensonqin@gmail.com>
A missing pangocairo/pangoft2/fontconfig used to produce empty cflags
and a later missing-header error. The rule now exits so the configure
failure is visible.

Co-authored-by: Tienson Qin <tiensonqin@gmail.com>
…oops.

macOS, Linux and Windows window loops call Lui_app.tick_clock and
Lui_host.tick every iteration, fold Lui_clock.next_delay into the wait,
drain Lui_resource, and wake on completions. Demo toast_since clocks
are gone. Linux watches DBus fds instead of a 50ms idle cap, recreates
only the Vulkan frame on resize, uploads damaged rows, and treats blit
resize failure as a demotion. Swapchain present is documented as a
follow-up.

Co-authored-by: Tienson Qin <tiensonqin@gmail.com>

@devin-ai-integration devin-ai-integration Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Newer findings are available below. Devin Review posted a newer report on this PR, in addition to the findings presented here.

Devin Review found 10 potential issues.

Devin Review

Comment thread platform/native/lui_window/main.ml Resolved
(with-stdout-to %{target}
(bash
"case '%{system}' in linux) printf '(%s)' \"$(pkg-config --cflags pangocairo pangoft2 fontconfig 2>/dev/null)\";; *) printf '()';; esac"))))
"case '%{system}' in linux) flags=$(pkg-config --cflags pangocairo pangoft2 fontconfig) || exit; printf '(%s)' \"$flags\";; *) printf '()';; esac"))))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Build edits lack required authorization

The PR modifies four dune files across Pango and the native hosts. AGENTS.md requires explicit authorization for such edits; the supplied context contains none.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Invalidate Vulkan damage after blit resize so window moves re-upload.
Keep the blit cell after a resize error so later events can retry.
Sample the Linux/Windows clocks after draining events so scrollbar
ticks stay monotonic. macOS wait no longer zeros Frame.Wait_ms.
Windows idle Sleep is capped at 4ms so input still drains. D-Bus
watch uses a C select on raw fds; GTK keeps a 50ms GLib wake.
Resource spawn failures notify watchers. Terminal pending writes
use a two-list queue.

Co-authored-by: Tienson Qin <tiensonqin@gmail.com>
devin-ai-integration[bot]

This comment was marked as resolved.

A Failed on_state callback can reload immediately. Notifying from spawn
before request/reload stored the result overwrote the retry's task with
None, so scope disposal could not cancel it.

Co-authored-by: Tienson Qin <tiensonqin@gmail.com>
@tiensonqin
tiensonqin merged commit 5ac41ab into main Nov 20, 2026
9 of 10 checks 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.

2 participants