Repository navigation
Ariadne in the browser: windows open inside the canvas and follow it as it resizes - #977
Merged
Merged
Conversation
In a browser VTK fits the canvas to its container only when it handles a resize event, and the first one comes from a ResizeObserver after the first frames have drawn at the window's starting size. cyprty starts at arigl's 1024x768, so ImGui placed every window against that, and on a shorter canvas (577-729 px tall in a laptop's browser) windows ran off the bottom: the "opens inside the view" rule (ARIADNE.md 5.8) had moved them in for a view that was not there. ViewportManager now takes the container's size right after the interactor initializes, as VTK's own resize handling would. With the real size from frame 1, the overlay's small-screen rule would start a 1366x768 laptop's browser with its panels hidden (short side under 700). It is a phone's rule, so the line is now 500 logical px, the phone view libcvc#974 uses. cvcgl_imgui_panels_start checks both sides.
Checked in headless Chrome at 1366x768: with the canvas sized before the first frame, the Avatar window was placed in a 597-px stage, and a frame later the stage was 578. The footer is empty until the program first prints, then a line taller. It is one line tall from the start now, in cyprty and the cvcGL demo page, so the canvas keeps the size the windows were placed in. When the overlay hides its panels on a phone, it writes that to its state mirror, as the show/hide button does, so ui.panels_open says what shows. cvcgl_imgui_panels_start renders three frames per window: the overlay's GL backend starts at the first render, so ImGui's first frame is the second.
The first is the window resize event the wasm interactor's Initialize() dispatches, handled at the next processUIEvents(), not a ResizeObserver as the comment (and the first commit's message) said. Checked in Chrome: with the container held at 0 px past that event, the canvas stayed 0 px tall after the container got its height, until a window resize event.
A window opened inside the view (5.8), but if the view got smaller after (a browser window made smaller, a phone turned on its side, fullscreen left), nothing brought it back: on a shorter canvas the windows below its new edge stayed there. Each window now keeps the work area it was last drawn in. When it is drawn in a smaller one, a window that showed in full there moves back in as it opened, no larger than the work area. A window the user left partly outside stays where it is, a view that grows again moves nothing, and the flow places its windows itself, as before. cvcgl_imgui_view_shrink checks it on a bare ImGui context: 1600x900, then 1350x579 (a 1366x768 laptop's browser canvas), 1350x450 and 500x450, then back; and a window dragged past the bottom edge. Against the old ImGuiBackend.cpp 5 of its 11 checks fail.
A window moved in to fit the view, where it opened or when the view got smaller, now keeps its home: the place and size it had without the move. Each frame it heads there as far as the view allows, so a view that grows again returns it, and a page opened in a small browser window and then made larger puts the windows where the document says. It is home again when it gets there. If the user has moved or resized it since it was last put somewhere, where they put it is its place from then on. cvcgl_imgui_view_shrink: back at 1600x900 every window is where its pos: says at its size; a page opened at 1350x579 goes back part way at 1450x700 and all the way at 1600x900; a window the user drags after it was moved in stays there. 16 checks.
#974 (windows as a list of titles on a phone) and this branch both changed where ImGuiBackend::begin_window opens a window. Both stay: a window that does not fit a phone's view opens collapsed in the list, and one moved in anywhere else keeps its home. A window in the list gets no home: one would pull it back out of the list, on the phone and again when the view grows. reset_layout clears the list count, the last views and the homes. cvcgl_imgui_view_shrink gains the case (it fails without the rule), and section 5.8 says a window in a phone's list stays there.
This was referenced Nov 3, 2026
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.
The browser conference page opened its windows as if the canvas were 1024 x 768, and no window moved when the canvas changed size later. On a laptop's browser canvas, 578 to 729 px tall, windows ran off the bottom. In the conference that was the Avatar window, and on #972's branch also the Chat window's message field. Found while testing #972 in headless Chrome.
Why
ARIADNE.md §5.8 says a window opens inside the view: no larger than the work area, and moved in from its
pos:until all of it shows. ImGuiBackend does that once, where the window opens. In a browser the view it opened in was the wrong size:run_window, when there is no--width/--height).ExpandCanvasToContainer), but only when it handles a windowresizeevent. The first one is the eventInitialize()dispatches itself, and it is handled at the next frame'sProcessEvents().Native arigl was always right, because its window has its real size from the first frame.
The fix
ViewportManager(wasm only). Right after the interactor initializes, it takes the canvas container's size, as VTK's resize handling would (vtkGetParentElementBoundingRectSize, thenUpdateSize, which also sets the interactor's height for mouse y). This covers every cvcGL page, not only the conference. A container with no size yet keeps the size the app asked for.ImGuiOverlaystarts its panels hidden when the view's short side is under 700 logical px, decided on the first frame. That was only safe because the first frame was 768 tall. With the real size, a 1366 x 768 laptop's browser (a 578-px canvas) would start with every panel hidden. It is a phone's rule, so the line is now 500, the phone view arigl on a phone: windows as a list, labels in view #974 uses (phones are 360 to 430 on their short side). The decision is also written to the state mirror, as the show/hide button's is, soui.panels_opensays what shows.ImGuiBackendkeeps the work area each window was last drawn in. When a window is drawn in a smaller one, and it showed in full in the old one, it moves back in as it opened, no larger than the work area.m_home). Each frame it heads there as far as the view allows, so it goes back out as the view grows, and forgets its home once it arrives. A page opened in a small browser window and then enlarged ends up laid out as the document says.Not changed
ImGuiBackend.hand in three spots inImGuiBackend.cpp. The fix is to keep both sides, with one rule: a stacked window gets no home, so the seed block'sif (!existing)becomesif (!existing && !stack). Without that, a stacked window would head back toward its authored place and undo the stacking. ARIADNE.md merges cleanly.Testing
In a browser. I built the conference page for wasm from this branch and ran it in headless Chrome over DevTools against a local WebSocket arisrv. A script logged the canvas's backing size on every animation frame.
Before the footer change, the canvas was 1348 x 597 for one frame and then 1348 x 578, which left the Avatar window 19 px off the bottom.
A resize after load. I loaded the page at 1600 x 900 and then resized the browser window to 1366 x 768 over DevTools (
Browser.setWindowBounds, a real resize). In both builds the canvas went from 1584 x 730 to 1350 x 579.Against the production relay. I loaded the page from this branch against the production relay's WebSocket. It joined the live room (44 ms ping), the Avatar window loaded its catalog and energy budget from the relay, and the resize behaved the same. The relay code differs from the live relay's commit (6a014a1) only in logging and performance.
A GPU reset I couldn't tie to the change. While builds were running, Chrome's GPU process was reset (
DXGI_ERROR_DEVICE_HUNG) 5 times in 4 phone runs of this branch. In the same period, 2 runs of #972's build were not reset. Two of the 5 resets came with this branch's sizing step skipped (the page held the canvas's container at 0 px until VTK had made its window).I then alternated fresh-profile phone runs, idle and with a wasm build running:
ViewportManager.cppandImGuiOverlay.cpp: 5 runs, no resets;Native (Windows, MSVC 14.44, shared, RelWithDebInfo):
The new
cvcgl_imgui_panels_startchecks that the panels start open on 1348 x 577, 1582 x 729, 1024 x 768 and a 125% 1920 x 810, and hidden on a phone either way up.The new
cvcgl_imgui_view_shrinkruns on a bare ImGui context:pos:and size again;It passes 16 of 16 checks. Against master's
ImGuiBackend.cpp, the shrink checks fail (5 of the first 11).With both,
cvcgl_imgui_*(10 tests),cvcgl_ari_golden,cvcgl_ari_switchandcvcgl_streaming_overlays: 13 of 13 pass.ariadne_runtime_testpasses 248;ariadne_loader_testpasses 213, with 2 skipped.