Repository navigation
merge: sync upstream main (68be843c) into the fork - #57
Merged
Merged
Conversation
Every changed frame reset the command pool and re-recorded the whole scene for every swapchain image, so a caret blink, which changes one rectangle's instance data, recorded thousands of vkCmd calls three times. The renderer now keeps a generation of what the commands draw: the compositing batches, the label textures, the scene buffer and the extent. A frame that changes one of those advances it; each image keeps the generation it was recorded at and is recorded again, alone, when it is acquired with stale commands. A frame that only writes instance data records nothing. The command pool resets buffers individually, and the offscreen target records before its readback. Stage 1 of ADR 0091. Checked on the Linux test machine (lavapipe): the recording, offscreen and window-recovery tests pass. Viva-only.
… tables Loading the xcb and Vulkan function tables once handed every caller the same table, so a window or renderer whose functions were wrapped (as the recovery and resize tests wrap them) changed every other one in the process. The libraries are still opened and bound once; each caller now gets a copy of the bound table, a few hundred bytes per window. Follows ADR 0093 step 1 (9ad1e9d). Viva-only.
… the GPU Each changed label made and freed its own staging buffer and memory, and every upload ended with vkDeviceWaitIdle, stalling the whole GPU once per batch of changed rows. Uploads now copy into staging chunks the renderer keeps, persistently mapped; a page that outgrows a chunk takes another, and the next upload merges them into one. An upload fence replaces the device wait: the next upload, or the next frame that replaces label images, waits for it, and the frame drawn after an upload reads its images through the barriers recorded with the copies. Loading the Vulkan table also gives each renderer its own copy of it. ADR 0091 stage 3, staging and synchronization; image sub-allocation is next. Checked on the Linux test machine (lavapipe): the new staging test, the offscreen text tests and window recovery pass. Viva-only.
Every uploaded label image made its own vkAllocateMemory, a kernel call against a driver limit of a few thousand allocations, and freed it when the row changed. Label images now take aligned spans of 16 MiB blocks per memory type; a freed span joins its neighbours, a block left empty is freed unless it is the last, and an image larger than a quarter block keeps memory of its own. Replacing twelve rows after a large page makes no image allocation. ADR 0091 stage 3, image memory. Checked on the Linux test machine (lavapipe): the pool, staging and offscreen text tests pass. Viva-only.
Every clipboard or primary read opened an X connection, made a 1x1 input window, interned its atoms with a round trip each and tore it all down afterwards; Motty's remote desktop does that on every pointer press. Reads now share one process connection and window, made by the first read and kept: a mutex lets one read wait for its replies at a time, replies left over from a read that gave up are dropped before the next, a connection the server dropped is made again, and the connection keeps the atoms it resolved. Font settings are read once already, and a global shortcut keeps its own connection for its key events. ADR 0093 step 2. Checked on the Linux test machine with xclip: the primary, INCR both ways, clipboard manager and new shared-connection tests pass. Viva-only.
The Editor read and wrote its []rune directly in some 150 places: length, indexing, slicing, grapheme boundaries and the tail shuffle of every edit. They go through runeStore now (Len, At, Slice, View, Next, Prev, Replace, String), still backed by a []rune, so the text can change how it is held without touching the editing code. No behavior changes. Step 1 of ADR 0092 (editor text storage). Viva-only.
The editor kept its text as one []rune (four bytes a character) next to the cached String, and every edit moved the rune array's tail. The rune store now holds UTF-8 in leaves of about 2 KiB, each counting its runes, bytes, UTF-16 units and newlines, with running totals over the leaves: rune index, byte offset, UTF-16 offset and line convert through a binary search and a walk inside one leaf, an edit inside a leaf is made in place, and String rebuilds only the edited span in one copy. ByteOffset, RuneIndex, the UTF-16 conversions, line starts and ends and the line journal read the store instead of walking runes from a remembered offset. The input method planner reads the text, and the text before its tentative suffix, through a small interface instead of materialising every rune once per event. Public API is unchanged (indexes are still runes). Measured on M2 Pro: retained memory 3.3 -> 1.0 bytes per byte of text at 1 MiB and 16 MiB; an insert and delete in a 1 MiB document 254 -> ~150 us; arrow keys on a short mixed line cost ~60 ns more per step. ADR 0092 step 2.
A CodeEditor laid out every row again whenever Value changed, so one keystroke in a megabyte of text cost about 8.6 ms, longer than a frame. When only the text changed, the editor now finds the edit from the bytes the old and new text share at either end (compared a block at a time), lays out again the logical lines holding it, and moves the rows after them by the bytes and lines it added. Indent guide levels are kept the same way: the edited lines are measured again and the blank lines next to them resolved again. Folds, a change of width, wrap, tab width or representations still take the full layout. The snapshot API is unchanged: callers keep passing Value. Measured on M2 Pro with 1 MiB of text: relayout on edit 8.6 ms -> ~0.11 ms with and without wrapping or indent guides (most of what is left is the benchmark building the new string). ADR 0092 step 3 (CodeEditor part).
59c733f made NewEditor copy its argument twice (to bytes, then into a leaf), rebuild String from the leaves on first read, and grow past the inlining budget, so a short-lived editor no longer stayed on the stack: TestDefaultStateSnapshotPreservesConstructionAllocations went from 2 allocations to 6. Leaves are now cut straight from the string, a UTF-8 initial text is kept as the cached String, and NewEditor is a small wrapper the compiler inlines.
A newly appearing Autofocus hit, a paint-time RequestFocus or ReleaseFocus, or a ReturnFocus scope closing moved the focus only when publish synced it, after the frame was painted: the frame showed the old focus and nothing painted again until the next event. repaint now settles the focus before publishing (sync, and paint again if the focus moved, at most twice), covering the cases it already handled for carried requests and modal scopes. The hit comparison is remembered for the paint, so settling and publishing compare the list once.
Focus.Sync built the regions in a slice of its own and Router.SetRegions copied them into another, compared against the previous list, so every interactive element was held twice (48 bytes each) and each change was copied. Focus now builds the list in the router's own buffer (Router.RegionBuffer) and the router keeps it as given. The equality shortcut goes with the copy; the painter already skips Sync when the regions' inputs are unchanged, so it only saved a rescan for the focused slot.
Each window made its own Vulkan instance, chose a physical device, and created a logical device and queue, so a second window paid the driver start-up again and kept a second device resident. Windows now share a process-level vulkanDevice: the first window creates the instance, chooses the device for its surface and creates it; later windows make only their surface on that instance and check the queue can present to it; the last window to close destroys it. The windows render on the application's one loop thread, so the queue needs no lock. A device loss retires the device for every window: the window that finds out makes itself again on a new device, and others keep the old one until their own next call reports the loss, then release it (the last release destroys it) and join the new one. A surface loss still rebuilds only that window. Offscreen renderers keep a device of their own. Measured on the Linux test machine (lavapipe): a second window's renderer opens in 7.7 ms instead of 13.7 ms, and each extra window adds 1.9 MB resident instead of 6.4 MB. A shared VkPipelineCache was tried and gave nothing measurable over Mesa's shader cache, so it is not added. Also give TestPresentOutOfDateRebuilds' fake renderer the framebuffer its command buffer records into; 0a34cde made present record lazily and the fake had none, so the test panicked. ADR 0093 decision 3.
Pages had no shared way to change their layout with their size: each
wrote its own `if c.Bounds().Width < N`, and nothing could ask how wide
the part of the page an element sits in is.
Box.From(breakpoint, change) applies change, made of the Box's own
methods, from that breakpoint on, mobile first:
ui.Column(c).Gap(8).From(ui.Medium, func(b ui.Box) { b.Row().Gap(16) })
The breakpoints are Material 3's window size classes (Compact, Medium,
Expanded, Large, ExtraLarge: 0, 600, 840, 1200, 1600), measured on the
page, and Width(n), measured on the nearest Container: a Column whose
width comes from where it is placed, never from what it holds (CSS's
inline-size containment). Container queries are answered from the
Container's last layout; when the layout gives another answer the page
is declared again within the same Draw, reusing the Memo retry, and the
containment makes the second answer agree. A steady paint declares once
and allocates nothing. Ctx.SizeClass and Ctx.AtLeast answer the same
questions for code that branches. Row and Column may now change a Row's
or a Column's direction, the change From is most often asked for.
The paired Motty commit lays out the remote tools' toolbar with it.
A responsive change could alter an element but not take it away:
hiding meant wrapping it in an if, which the narrow layout of a
Container cannot do, as a container query is answered with From.
Box.Hide takes the element out of the page as CSS's display: none: at
End, before layout, it is detached from its container, so it takes no
room, is not painted and gives no hit, focus region or accessibility
node. What it holds is still declared and keeps its identities and
state, and Show undoes it:
ui.Text(c, host.Address).Hide().From(ui.Expanded, func(b ui.Box) { b.Show() })
ADR 0094.
app.TitlebarInsets answered per platform, the same for every window and at every moment, so a page kept room for the traffic lights or the window buttons in full screen, where they are not on its strip, and in windows whose titlebar is the system's. The runtime now hands each paint the insets of the window it paints (Canvas.TitlebarInsets, ui.C.TitlebarInsets): the platform's buttons for a custom titlebar, none in full screen or under a system titlebar. app.TitlebarInsets is removed; the paired Motty commit reads the insets from the canvas. ADR 0094.
0747528 dropped Router.SetRegions' early return for an unchanged list, which had also kept focusedSlot; every repaint then put the focus on the target's first region. A target with two focusable regions sent Tab from its second region back to its first, so traversal looped there and never reached the controls after it (Motty's TestWorkspaceTemplateManagementThroughKeyboard). SetRegions now keeps the slot while it still holds the focused target, and searches only when it does not.
… presses A finger's press was read as a mouse's: it pressed at once, so a swipe over a list pressed and clicked what it started on, nothing scrolled, and there was no long press. Pointer events now say what they come from (gfx.PointerDevice: mouse, touch, pen) and which finger (PointerID), and the runtime reads a finger as Android and UIKit do (interaction.Touch, shared by the native runtime and the browser's): - a still finger presses after a 100 ms tap timeout, or as it lifts sooner (a tap), so a pan that starts at once presses nothing; - moving more than 8 px first makes it a pan that scrolls what was under it, the content following the finger; - lifting while moving flings with UIScrollView's deceleration, asking for frames only while it moves and allocating nothing per frame; - held still for 500 ms it ends the primary press and is a secondary press, which opens context menus; - a slider or a divider presses at once and takes the drag; - quick taps in one place count as a double tap; a finger hovers only while it touches. Mouse and pen input is unchanged. The browser maps pointerType and pointerId. Windows, Linux, the browser and phones install the touch runtime; macOS, which has no touch screen, does not link it. hello grows by about 500 bytes of code (its stripped size by one page). Windows and Linux still report touch as the mouse their systems promote it to; their native touch events are the next step. ADR 0095 phase 1.
…f it On hosted macOS runners hdiutil convert kept failing with "Resource temporarily unavailable" after the writable image was detached, even through ten retries over 45 seconds (TestBuiltImageHoldsTheLayoutTheFinderReads failed four times on main since 3a8af08). Detaching returns before the service releases the file, so retrying on time alone guessed. The build now waits until hdiutil info no longer lists the image, up to two minutes, and reports what still holds it if it never lets go.
GOOS=ios also satisfies the darwin build constraint, so every AppKit, FSEvents and Dock file was compiled for iOS and the build failed at the first of them. Files that belong to macOS alone now say so: the whole internal/platform/darwin package, the audio and file-watch backends, the darwin hooks of app, the proxy, headless and visual-parity tools and their tests carry `&& !ios`. Where iOS then has nothing of its own yet, app/ios_unsupported.go reports that the system does not offer it (the clipboard, dialogs, notifications, the cursor, global shortcuts, fonts, the native run loop), each moving out as the backend lands (ADR 0095); the touch runtime is installed on iOS as on every platform but macOS. `GOOS=ios go build ./...` and `go vet ./...` now pass; the desktop builds are unchanged: macOS, Linux, Windows and browser vet pass, and hello for macOS is the same size, 4,442,994 bytes. ADR 0095 W0 (iOS part).
native.m held, in one 8,700-line file, the system fonts and shaped lines, the label textures, the Metal pipelines and scene encoding, and the AppKit view, window and application that use them. The window, the offscreen renderer and the native editor all draw through the same code, but nothing said so, and nothing but AppKit could reach it. The first part moves, without a change of behavior, into core_text.m (fonts, shaped lines, the monospace fallbacks, the editor's line and its texture) and core_render.m (pipelines, label reuse and hashing, the label layer and the encoding of a scene); core.h declares what they share, and the counters the render code keeps are defined there. The native test programs, which include native.m as one translation unit, include the two new files too. hello for macOS is 4,288 bytes larger (4,442,994 to 4,447,282): its functions are no longer inlined across files. ADR 0095 W1, step 1.
… renderer VivaMetalView held, next to its events, text input and accessibility, the whole of what it draws: the rectangle buffer and its clips, the label layers, the composite plan, the pipelines and the command queue, and the code that updates, encodes, presents and recovers them. Nothing but an NSView could reach it. That part is now VivaRenderer in core_render.m, over a CAMetalLayer it is given: building a scene, updating its rectangles and labels, rendering into a drawable, drawing the labels' textures again and making the Metal resources again after the device is lost. The view creates one and forwards to it; the composite planning and the remembered shader library moved with it. The text and rendering core (core_text.m, core_render.m, core.h) no longer uses AppKit classes: geometry is CoreGraphics, fonts and colors go through VivaFont and VivaColor and the few calls that differ (the font manager, color conversion) through small shims, so the same files compile against the iOS SDK. A shared-mode buffer is no longer told it was modified on iOS, where that call does not exist. Behavior is unchanged: the darwin tests pass as before, and the native test programs still build. hello for macOS grows by 848 bytes (4,447,282 to 4,448,130). ADR 0095 W1, step 2.
…nderer The iOS backend shares internal/platform/darwin with macOS, split by build tag: the Go side that encodes frames, shapes text and routes callbacks is the same, and cgo types cannot cross packages. ios_host.m answers the same C interface as the AppKit host with one full-screen UIView over a CAMetalLayer, touches forwarded as touch pointers, and a single window (a second one is refused). The Go program runs as the executable: UIApplicationMain starts it and the application's start runs from didFinishLaunching. Shader libraries are built for macOS, iOS devices and the iOS simulator and chosen at run time. The macOS shader library is unchanged. Not yet: safe area, keyboard, accessibility, lifecycle, device runs.
build --target ios-sim|ios writes an .app: the program built with cgo against the Xcode SDK of the target, and an Info.plist from viva.toml. run builds one for the simulator, boots a device when none is, installs and starts it; the device comes from --device, else a booted iPhone, else the newest installed. Signing for devices and the Xcode export are still to do.
The renderer and its device, scene, text and frame code move from internal/platform/linux to internal/platform/vulkan, which knows no window system: a window system gives it a SurfaceSource (the instance extension and the call that makes the surface), and the platform gives it a TextRasterizer that draws label glyphs. Linux supplies the XCB surface and its Pango text services; the driver search for desktop manifests stays with desktop Linux (libvulkan.so.1), and Android will supply an ANativeWindow surface and the system's text drawing with libvulkan.so. Window-system-neutral pieces move to where both renderers reach them: the frame geometry (platform/windowframe), the label and rectangle validation (platform, render) and the font size check. The Linux window keeps its windowRenderer seam and adapts the Vulkan renderer to it. Tests move with what they test. The renderer's recovery and device tests now present to an X window made with a few libxcb calls, or to a headless surface, and use a solid text rasterizer; the window's resize tests use a fake renderer; the ones that need Pango and renderer internals together keep to Linux through small exported counters. Two test fixtures that never set the window's text input are fixed. The Linux hello grows by 12,288 bytes (0.2%): the adapter and the exported renderer API.
…latforms The browser's text engine is geometry over two measurements the platform gives: the width of a line and the extent of each grapheme cluster. It has no system call in it, so it moves to internal/lineengine, tested on the host, and the browser supplies its Canvas and DOM measurements as a Measurer. A platform whose system lays a line out for it, such as Android, supplies its own. The interface family and the font generation are process-wide there, as the native engines' are.
…ulkan The program is a shared library that the host's Activity loads; the host owns the UI thread, the surface and the keyboard, and the program draws on the surface with the Vulkan renderer from a thread of its own, idle between the events the host queues. Java reaches Go through fixed JNI entry points, Go reaches the system's text drawing through a few static Java methods, and the program's main runs after the host starts it (go:linkname to main.main). Text is the shared line engine (moved from the browser backend to internal/lineengine) over Paint and Minikin, with labels drawn by Canvas. The renderer keeps its device, scene and label textures when the system takes the surface back and gives it again. viva build --target android writes a signed APK with the NDK's compiler, javac, d8, aapt2, zipalign and apksigner, with no Gradle; viva run --target android installs it with adb and starts it. CI builds hello for both ABIs. GOOS=android satisfies linux, so the desktop Linux files carry !android and the !linux fallbacks include it. Desktop hello sizes: Linux +12,288 bytes, macOS +5,264, Windows unchanged. Not yet: input method, accessibility, insets API, device runs.
…hole disk image The Vulkan renderer's shaders and compositing-layer tests moved to internal/platform/vulkan; the shader generator, the vector coverage job and the text input job still looked under internal/platform/linux. The disk image test failed on macOS runners with the image still attached after detaching: the device node detach was given is the volume's partition, which unmounts the volume and leaves the image attached. It is given the whole disk.
An image whose volume the system had unmounted stayed attached, and the disk image service kept holding the file.
A finger and the fling it leaves give at the end of scrollable content like the system's bounce: the content follows at a fraction, a fling gives by one step of what it had left, and the content returns when the finger lifts. Wheels and touchpads still stop at the end.
A touch that lands within reach of a small control, not on it, presses the control rather than what is behind it. The control is drawn as before.
An image whose volume was already unmounted was detached once and left attached when the service was busy; retry and force it like a mounted one.
WM_POINTER messages of touch pointers reach the window as touch events, so pan, fling, long press and the other gestures work. Mouse and pen are left to the default procedure as before.
A window selects the touch events of X Input 2.2 and reads touch begin, update and end as touch pointers, so pan, fling and long press work. A server or machine without the extension keeps the finger as the pointer.
…folder On a loaded runner create answers No such file or directory with the folder there, as the disk image service starts; wait it out like a busy service.
A detach that reported success could leave the image attached and the file held for minutes on a loaded runner; release now detaches the disk again at intervals.
A long press on a control that has a tooltip and takes no context menu shows the tooltip for a moment, as Material and Android's tooltipText do on touch.
Phone windows now fill the screen; Size.SafeArea, Canvas.SafeArea and ui.SafeArea keep content inside the bars. app.Config.OnLifecycle reports Background, Foreground and MemoryWarning on iOS and Android. Also fixes the screen staying stale after returning to the app (iOS redraws when active; Android presents again after the surface is replaced) and an allocation in the tooltip paint.
The reference component changed with the touch tooltip.
…uched The touch tooltip read the pointer pass on every paint, which made a mouse-only window repaint once more per pointer event.
On a phone setCursor answers ErrUnsupported, which ended the window as soon as a control asked for a pointer shape: holding a text field closed the app.
a6ae841 brought the English README, the conformance table and both input guides in line with the Fcitx 4 client, but README.zh-CN.md kept saying Linux composes through IBus alone. Its overview now matches the English one: IBus, Fcitx5's IBus frontend or Fcitx 4's own protocol. Refs: t8y2/motty#1165
…sh at once The host now implements SurfaceHolder.Callback2.surfaceRedrawNeeded, so the system shows a new surface only after the window is presented on it; this replaces the second present after returning to the app. It also removes the splash screen itself, whose reveal stopped part way over the surface and left the window faded after a fresh install.
… finger Text fields answer where their text is (index at a point, caret, range rectangles), so a finger places the caret in any field and a long press selects the word under it. Fields take the long press over a tooltip.
# Conflicts: # app/painter.go # base/scroll.go
This was referenced Nov 23, 2026
fix(viva): 固定版本升到同步上游后的 fork main 3c6c4608,跟随 TitlebarInsets 与 PopoverWith 的新写法
1lck/Lithe-IDEA#2336
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
发布 Lithe 桌面端 0.8.15 前的上游同步。把
vivaui/vivamain(68be843c)合进 forkmain(103c1952),带来 64 个上游提交。上游带来的主要变化
4472fc85),编辑器文本改为 UTF-8 叶子节点、通过 store 访问 runes(59c733f2、b108bb19),CodeEditor 只对编辑触及的行重新布局(932c9aae),双向文字的字形几何在语法着色、换行和制表符下保持(68be843c、ee7ba130、e320ba5d),CodeEditor 的定位不再切断字素簇(302faef4)。6d2fd9b0),每个窗口共用一个 Vulkan 设备,标签图像内存分块子分配,输入区域只在路由里保存一份。base.Hide/base.Show(05804abe)、base.From按窗口或容器宽度响应(a96c6733)、Config.CaptureMenuKeys(0f959e5c,菜单捕获按键时保留 IME 组字)。冲突与解决
两处冲突,都是上游和我们改到同一段代码,但解决的是不同问题,所以两边都保留;没有出现「上游用另一种做法解决了同一个问题」的情况。
app/painter.gocaptureMenuKeys,我们这一侧有 fork 独有的onFocusLostonFocusLost。painter结构体、focusLostHandler和focusLost的改动已自动合并,无需调整。base/scroll.goScrollState加了手指过界回弹的pull/touching/pullAt,并在wheelArea末尾加了「手指滚不动时交给最内层还能滚的区域」的兜底;我们这一侧有 fork 独有的barStyle(按区域覆盖滚动条几何)和panel限制(滚轮不穿透 Popover、Dialog、模态 Drawer)panel限制和within判断——否则手指在浮层上滚到底会带动底下的页面,正是 fork #40 要修的问题。ScrollPhaseEnd的提前返回补上manual返回值。我们的补丁
fork
main上没有待合入的 PR(gh pr list --repo Lithe-IDEA/Lithe-viva --state open为空),所有补丁都已经在main上,这次 merge 全部保留,没有需要 revert 的。a105ef83 fix(markdown): decode inline character references是从上游9707cce3cherry-pick 来的,上游以148d6dcb合入;这次 merge 自动合并,没有冲突。验证
go build ./...(darwin/arm64)GOOS=windows GOARCH=amd64 go build ./...、GOOS=windows GOARCH=arm64 go build ./...GOOS=linux GOARCH=amd64 go build ./...go test ./base/ ./app/ ./ui/ ./components/ ./markdown/ ./gfx/go test ./...cmd/viva的 dmg 与签名测试在本机失败:the program was built for macOS 13.0 or later but [mac] min_system says 12.0。在上游origin/main上直接跑同一个测试也是同样的失败,是本机 Xcode SDK 的部署目标造成的,与这次同步无关。go test ./...还报了build包编译失败:那是本机build/目录(.gitignore忽略)里一个上次会话留下的未跟踪基准文件pr349_wheel_bench_test.go,不在仓库里,也不随这次同步改变。