From c7d0b23d63146f0c0d7e746b135089c1704623fb Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Fri, 20 Nov 2026 12:17:28 +0100 Subject: [PATCH 01/10] WebFront 1.1.0 (#627) * Diagnose inherited Snap paths in WebKitGTK * Compare raw pointers in CaptureRegistration::reset Comparing std::shared_ptr found std::expected::operator== through ADL and made libc++ (AppleClang) recurse on its constraints. Compare the raw pointers instead. Fixes #606 * Respect environment variable path separators * Show the WebKitGTK window at its first frame, add a window background and cheaper font stacks (#611) * Initialize GStreamer only for applications with media; trace start-up since exec (#611) * Defer WebView2 window presentation until first frame * Fix Windows test discovery and release workflow checks * Detect native CUDA architectures for the host loop * Address review: GStreamer opt-out kept for the session and off by default no more, WKWebView presentation, WebView2 timers, docs, CI pin (#611) * Include NativeFS in the WKWebView lifecycle test (#611) * Let WKWebView's first-layout probe fall back to a timer when animation frames are throttled (#611) * Reveal the WKWebView window when the document has loaded instead of awaiting animation frames (#611) * Give the WKWebView first-load test a delay longer than a cold web content launch (#611) * Scope the GStreamer opt-out to the start of the session and test that unrelated children keep their environment (#611) * Arm the WebView2 presentation delay with the window; state the process-wide window of the GStreamer opt-out (#611) * Stop WKWebView painting its own white behind a transparent page and test the displayed pixels (#611) * Report the pixel read by the WKWebView background test (#611) * Check the WKWebView background through its state, not through unreliable pixel reads (#611) * Give the developer environment's window its dark colour by default to remove the white flash on navigation (#611) * Address review follow-ups: changelog wording, late first-frame milestone, WKWebView test naming (#611) * Make the WKWebView window non-opaque for a translucent background and test the alpha (#611) * Add optional native pseudoterminals (#613) * Harden PTY lifecycle and address review feedback (#613) * Fix hardened PTY build and Windows interrupt probe (#613) * Stabilize desktop CI discovery and DOM coroutine coverage * Accept ConPTY cursor positioning in the browser regression * Move PTY launch off the server and finish lifecycle review * Check PTY shell output independently of ANSI layout * Add the start-up time test, the font stack hint and CEF's background and deferred window (#611) - StartupTime-cold and -warm cases (label startup) run the lifecycle program's startup-time scenario with generous limits. - The development file system prints a hint once for a stylesheet whose font-family lists four or more costly families. - CEF applies WindowOptions::background and shows its window when the first document has loaded or after one second. - Document the critical path and prewarming analysis; update the expected test counts of the frontend selection checks. Refs #611 * Address the review of the start-up test and the font stack hint (#611) - NativeDebugFS reads a stylesheet only when it has not been checked yet and its size, taken before reading, is at most 1 MiB. - The font stack warning says that other engines are not affected this way. - The startup-time scenario closes the window on an empty answer or an exception, so a failure no longer waits for the script's timeout. - Document that the cold start-up case is fully cold on Linux only. Refs #611 * Isolate start-up scratch directories per frontend and key font checks by full path (#611) - The StartupTime cases use a scratch directory named after their frontend, so that CTest running two frontends in parallel no longer deletes each other's profile. - NativeDebugFS remembers the checked stylesheets by their path under the document root, so two roots serving a style.css are each analysed. Refs #611 * Time the whole start, clamp CEF alpha and recheck edited stylesheets (#611) - startup-time measures from the start of the program, so that the frontend's initialization is part of the limit. - CEF accepts only an opaque or fully transparent background alpha: a non-zero alpha is now opaque (as in WebView2) and only a zero alpha stays transparent. Documented and unit-tested. - NativeDebugFS checks a stylesheet again when its size or modification time changes, and still warns once per version. Refs #611 * Fix MSVC build of the font hint, isolate the WebView2 start-up profile (#611) Rename the 'version' stamp that hid webfront::version (C4459 under /WX), name the WebView2 user data folder of the start-up test, resume the font-family scan after the analysed declaration and restore the warning stream with a scope guard. * Format the stylesheet version without relying on the file clock's representation (#611) libc++'s file_time_type counts in a 128-bit integer, for which std::to_string is ambiguous: the version is now the count of nanoseconds. Refs #611 * Require the shown milestone, keep the file clock's own stamp and parse font-family declarations (#611) - The stylesheet stamp holds the file size and last write time as they are, built only after both reads succeeded, so no conversion of the file clock's count can overflow. - startup-time waits 1.5 s after the bridge's answer, and RunStartupTime.cmake fails when the window is not reported as shown or was shown after the limit. - font-family is read whatever its case, and quoted strings (a `content` value) are not declarations; a quoted family containing a semicolon no longer cuts its value. Refs #611 * Register the start-up tests only for frontends that declare STARTUP_TRACE (#611) RunStartupTime.cmake requires the `window shown` milestone that WEBFRONT_STARTUP_TRACE=1 prints, which the frontend contract does not ask for. A frontend added with webfront_register_frontend now opts in with STARTUP_TRACE (WebView2, WKWebView and WebKitGTK do); without it no start-up case is registered and the standard tier cannot fail on a missing trace. Refs #611 * Give the focus back to the developer terminal after a click on the page around it (#608) While the terminal has the window, the page around it (the title and the notice of the bootstrap page, blank areas) is not part of xterm.js. A click there moved the focus to the body: the cursor became a hollow box and the keys went nowhere, until a click inside the terminal. Once the click ends, the terminal takes the focus back, unless the click selected text, landed on a control, or an interface or the floating window owns the window. The regression spec clicks outside the terminal, then types. * Give the focus back only to the terminal that had it when a page holds several (#608) Each mount() added a listener on the whole document, so a click inside the first terminal also fired the second one's, which took the focus a moment later and sent the typed commands to the wrong session. The page now remembers which terminal was focused last: only that one answers a click on the page around the terminals, and a click inside any terminal is left to xterm.js. A listener removes itself once its terminal has left the page. The regression spec mounts a second terminal and clicks in each, then on the page. * Judge the click by where the press started, not by an older selection (#608) terminal.hasSelection() stays true after a selection made earlier, so a later click on a blank area of the page never gave the focus back and the keys still went nowhere. The page now notes where each press starts. The terminal takes the focus back only when the press began outside any terminal and control; a click outside cannot create an xterm.js selection, which is left alone. A selection of the page's own text still keeps the focus where the user put it. The regression spec selects the terminal's text, clicks the page and types. * Find the terminal to refocus from the focus at the press, not from focus events (#608) The last focused terminal was recorded from the textarea's focus event, which a window without the system focus never receives (several browsers on one display): no terminal then answered a click on the page. The press, which comes before the browser moves the focus, now records the terminal that holds it. The regression spec follows the browser's order: the focus moves to the body after the press, and clicks in a terminal leave it. * Leave the focus to the field a label hands it to (#608) A label was not among the elements that take a click, and the focus given back to the terminal after the click came after the browser had moved it to the label's field: the typing went into the terminal. A label now takes the click, and whatever field of the page holds the focus once the click has ended keeps it. The regression spec clicks a label and a page area while a field is focused. * Share the workspace state with every terminal of the page (#608) Only the first terminal mounted with a preview receives the workspace object; the others get null because the preview is already laid out. A second terminal that had the focus therefore ignored the state: with the terminal floating or an interface in the window, a click on the page gave it the focus back and took the keys away from the interface. The workspace now registers itself for its preview frame, and every terminal reads its state from there (it does not refocus while the state is unknown). The regression spec focuses the second terminal, shows an interface, clicks the page and checks that no terminal takes the focus. * Check again, when the focus is given back, that the terminal still answers (#608) The state of the workspace and the last focused terminal were checked at the end of the click, but the focus is given back in a task of its own. A click handler or a navigation that opened the interface in between still got the terminal's focus() call, with the interface now owning the window. The checks are one function, run at the release and again in the deferred task. The regression spec changes the state right after the click ends and checks that the second terminal does not take the focus. * Answer POST on a dynamic route that opts in, with a body bounded by Content-Length (#619) RouteOptions::postBodyLimit makes a route read the body announced by Content-Length, from the bytes received after the headers on, and give it to the handler as RouteRequest::body. Expect: 100-continue gets 100 Continue; a POST without Content-Length, with a Transfer-Encoding, with a malformed or contradictory length or a longer body is refused before the handler runs, and a connection that ends early is closed without an answer. * Name the 202 Accepted and 401 Unauthorized status codes (#619) A route that answers a notification without a body, or refuses missing credentials, gets a status line with its reason phrase. * Answer 100 Continue only to an HTTP/1.1 Expect token, test the interim cases and 401, document the limits (#619) * Accept spaces and equal lists in Content-Length, read a POST body without copies or oversized buffers (#619) * Accept optional whitespace in HTTP request headers (#621) * Test controls before HTTP header values (#621) * Use video without audio for HTTP playback regression (#621) * Bound CSS diagnostic reads and avoid GCC 13 iterator warning (#621) * Test Content-Length without a space after the colon and with tabs, now accepted by the parser (#619) * Read a header line fold as one space and keep the POST body alive while the answer streams (#619) * Keep the changelog entry of the line fold to ASCII, as its format check reads it (#619) * Read Expect as a list of tokens, so 100-continue among several is answered (#619) * Document that Expect lists 100-continue among tokens, without case (#619) * Pin developer environment 1.0.1 (#624) Co-authored-by: webfront-release[bot] * Prepare WebFront 1.1.0 (#625) --------- Co-authored-by: AM-L <35537869+AM-L@users.noreply.github.com> Co-authored-by: webfront-release[bot] <354514085+webfront-release[bot]@users.noreply.github.com> Co-authored-by: webfront-release[bot] --- AGENTS.md | 5 +- README.fr.md | 1 + README.md | 1 + cmake/BoingCuda.cmake | 10 + cmake/BoingCudaArchitectures.cmake | 51 + cmake/Frontends.cmake | 34 +- cmake/WKWebViewSupport.cmake | 2 +- cmake/WebKitGTKSupport.cmake | 2 +- cmake/WebView2Support.cmake | 4 +- docs/CHANGELOG.md | 31 +- docs/DEVELOPER_ENVIRONMENT.md | 7 +- docs/FRONTENDS.md | 6 +- docs/HOST_LOOP_EXAMPLE.md | 9 + docs/HTTP_ASSETS.md | 15 + docs/PROJECT_STATUS.md | 3 +- docs/PTY.md | 46 + docs/TEST_TIERS.md | 5 + docs/WEBKITGTK.md | 98 ++ docs/WEBVIEW2.md | 6 + docs/WKWEBVIEW.md | 8 + ...ADR-010-composants-et-outils-optionnels.md | 3 +- examples/host-loop/HostLoopUI.hpp | 6 +- examples/life/ui/style.css | 2 +- examples/pty/.gitignore | 1 + examples/pty/CMakeLists.txt | 12 + examples/pty/main.cpp | 39 + examples/pty/main.mjs | 47 + examples/pty/webfront-packages.lock.json | 342 +++++ examples/pty/webfront.project.json | 10 + include/webfront/Pty.hpp | 263 ++++ include/webfront/PtyPage.hpp | 125 ++ include/webfront/WebFront.hpp | 51 +- include/webfront/components/pty/Options.hpp | 49 + include/webfront/components/pty/Unix.hpp | 473 ++++++ include/webfront/components/pty/Windows.hpp | 382 +++++ include/webfront/frontend/CEF.hpp | 61 +- include/webfront/frontend/Capture.hpp | 2 +- include/webfront/frontend/WKWebView.hpp | 113 ++ include/webfront/frontend/WebKitGTK.hpp | 162 ++- include/webfront/frontend/WebKitGTKPolicy.hpp | 65 + include/webfront/frontend/WebView2.hpp | 110 +- include/webfront/frontend/Window.hpp | 50 +- include/webfront/http/Encodings.hpp | 6 +- include/webfront/http/HTTPServer.hpp | 190 ++- .../system/DeveloperIndexHtmlData.hpp | 30 +- .../webfront/system/DeveloperReleaseData.hpp | 6 +- .../webfront/system/FallbackIndexHtmlData.hpp | 63 +- include/webfront/system/FontStacks.hpp | 247 ++++ include/webfront/system/NativeFS.hpp | 37 +- include/webfront/system/WindowsArguments.hpp | 46 + include/webfront/testing/Process.hpp | 37 +- js/core/bootstrap/index.html | 2 +- js/core/fallback/index.html | 2 +- js/developer/environment/bundles.json | 14 +- js/developer/environment/runtime.mjs | 43 +- js/developer/environment/workspace.mjs | 16 +- js/developer/scripts/package-archive.mjs | 2 +- js/developer/scripts/pty-package.mjs | 6 + js/developer/starters/app/style.css | 2 +- js/developer/tools/distribution.json | 2 +- js/developer/webfront.project.json | 3 + js/pty/LICENSE | 1276 +++++++++++++++++ js/pty/README.md | 14 + js/pty/index.d.ts | 23 + js/pty/index.mjs | 128 ++ js/pty/package.json | 20 + test/cmake/CheckBddDiscovery.cmake | 30 +- test/cmake/CheckFrontendGenerators.cmake | 2 +- test/cmake/CheckFrontendSelection.cmake | 15 +- test/cmake/CheckReleaseWorkflowTests.cmake | 12 +- test/cmake/NodeGuardExceptions.cmake | 3 + test/cmake/PrepareSelfBuildProject.cmake | 1 + test/cmake/RunStartupTime.cmake | 71 + test/cmake/frontends/CMakeLists.txt | 2 +- test/driver/WfDriver.hpp | 5 +- test/fixtures/pty/Probe.cpp | 146 ++ test/tools/AutomationClient.py | 19 +- test/unit/BddDiscoverTests.cmake | 9 +- test/unit/CMakeLists.txt | 8 +- test/unit/DomDocumentTests.cpp | 13 + test/unit/EncodingsTests.cpp | 4 + test/unit/FrontendContractTests.cpp | 72 + test/unit/HTTPRoutesTests.cpp | 203 +++ test/unit/HTTPServerTests.cpp | 36 + test/unit/NativeFSTests.cpp | 101 +- test/unit/PtyTests.cpp | 328 +++++ test/unit/WebFrontTests.cpp | 47 + test/unit/WebKitGTKPolicyTests.cpp | 16 + test/unit/WebView2Tests.cpp | 67 + test/web/CMakeLists.txt | 6 +- test/web/FrontendLifecycle.cpp | 46 + test/web/JasmineTest.cpp | 31 +- test/web/WKWebViewLifecycle.cpp | 59 +- test/web/WebKitGTKLifecycle.cpp | 128 +- test/web/WebView2Lifecycle.cpp | 56 + test/web/developer-specs.mjs | 93 ++ test/web/first-frame.html | 8 + test/web/fixtures/media/README.md | 18 + test/web/fixtures/media/seek.webm | Bin 0 -> 5741 bytes test/web/registry/build.mjs | 4 +- test/web/suite/specs/pty-specs.mjs | 97 ++ test/web/suite/specs/webfront-specs.mjs | 14 +- test/web/suite/tsconfig.json | 1 + test/web/suite/types/pty.ts | 13 + test/web/suite/webfront.project.json | 3 + 105 files changed, 6507 insertions(+), 207 deletions(-) create mode 100644 cmake/BoingCudaArchitectures.cmake create mode 100644 docs/PTY.md create mode 100644 examples/pty/.gitignore create mode 100644 examples/pty/CMakeLists.txt create mode 100644 examples/pty/main.cpp create mode 100644 examples/pty/main.mjs create mode 100644 examples/pty/webfront-packages.lock.json create mode 100644 examples/pty/webfront.project.json create mode 100644 include/webfront/Pty.hpp create mode 100644 include/webfront/PtyPage.hpp create mode 100644 include/webfront/components/pty/Options.hpp create mode 100644 include/webfront/components/pty/Unix.hpp create mode 100644 include/webfront/components/pty/Windows.hpp create mode 100644 include/webfront/system/FontStacks.hpp create mode 100644 include/webfront/system/WindowsArguments.hpp create mode 100644 js/developer/scripts/pty-package.mjs create mode 100644 js/pty/LICENSE create mode 100644 js/pty/README.md create mode 100644 js/pty/index.d.ts create mode 100644 js/pty/index.mjs create mode 100644 js/pty/package.json create mode 100644 test/cmake/RunStartupTime.cmake create mode 100644 test/fixtures/pty/Probe.cpp create mode 100644 test/unit/PtyTests.cpp create mode 100644 test/web/first-frame.html create mode 100644 test/web/fixtures/media/README.md create mode 100644 test/web/fixtures/media/seek.webm create mode 100644 test/web/suite/specs/pty-specs.mjs create mode 100644 test/web/suite/types/pty.ts diff --git a/AGENTS.md b/AGENTS.md index a9c66cc5..8058affa 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -21,10 +21,11 @@ The README introduces WebFront through the Game of Life walkthrough, demonstrati - `include/webfront/weblink/`: bridge message encoding and routing. - `include/webfront/system/`: layered virtual filesystems and the embedded web resources, a closed list guarded by the `MinimalCoreAssets` CTest case (normative list and 150 KiB decoded budget in ADR-016; changing it means amending the ADR and `test/cmake/CheckMinimalCoreAssets.cmake` together). - `include/webfront/frontend/`: system-browser, CEF, optional Windows WebView2 and macOS WKWebView frontend adapters. -- `examples/`: only Hello World (`hello-world/`), the host loop (`host-loop/`: an application that keeps its own loop, `app.start()` or a host thread beside a native window; it ray-traces a Boing Ball on the CPU or with an optional CUDA unit, see `docs/HOST_LOOP_EXAMPLE.md`) and Game of Life (`life/`, with console, developer and embedded stages, plus the `life/react/` variant with a C++ panel inside React). +- `examples/`: the default build includes Hello World (`hello-world/`), the host loop (`host-loop/`: an application that keeps its own loop, `app.start()` or a host thread beside a native window; it ray-traces a Boing Ball on the CPU or with an optional CUDA unit, see `docs/HOST_LOOP_EXAMPLE.md`) and Game of Life (`life/`, with console, developer and embedded stages, plus the `life/react/` variant with a C++ panel inside React). The standalone [PTY example](docs/PTY.md) has its own CMake entry point. - `js/core/`: readable browser bridge, fallback and bootstrap loader compiled into `include/webfront/`, plus the embedding CMake modules; `js/developer/`: developer environment (its terminal and `wf`), the wf scripts that build it (`scripts/`), build and publication tools. The repository is itself a `wf` project (`js/developer/webfront.project.json` and its lock, selected with `--manifest-dir js/developer`): the environment builds itself, and its pure JavaScript specs (`test/developer/`) run with `wf test`. Production C++ remains header-only in `include/webfront/`. - `js/developer/starters/`: the sources of the `app` starter and `agent-guide.md`, the `AGENTS.md` that `wf create` puts beside a starter and that `webfront_write_agent_guide()` (`cmake/WebFrontAgentGuide.cmake`) writes in a consuming project. - `js/services/`: optional `@webfront/services` package, the browser side of the system services (ADR-020; a skeleton so far), built like `@webfront/react` by `wf run services-package`; outside the core's embedded resource list. +- `js/pty/`: optional `@webfront/pty` adapter for native pseudoterminals. `wf run pty-package` assembles the archive used by the browser tests. See `docs/PTY.md`. - `js/react/`: optional `@webfront/react` package (`createStore`, `useStore`, `Island`), declarations and package-local license. `wf run react-package` assembles it; tests verify the exact archive installed by the registry. It is outside the core's embedded resource list. - `test/fixtures/`, `test/web/fixtures/`: retained regression fixtures, not public example applications. - `test/unit/`: C++ unit tests, written with `test/unit/Bdd.hpp` (a single-header BDD framework); `test/web/`: real-browser integration (`suite/` is the WebFront project of the Jasmine specs, run by `webtest` through `wf test`); `test/driver/`: `webfront-wf`, the non-interactive `wf` driver for tests; `test/fuzz/`, `test/fixtures/`; `test/cmake/`: CMake test scripts and sub-projects. The `RepositoryLayout` CTest case pins the tracked root. @@ -116,7 +117,7 @@ Exception: a purely C++ change that reuses an existing encoding, introduces no n ## Coding and testing conventions - Use C++23, four-space indentation, the `.clang-format` of the directory (`include/webfront/`, `test/`, `examples/`), and the naming rules in `.github/CONTRIBUTING.md`. -- Keep production implementation header-only under `include/`; `examples/` contains the three public examples; browser resources live in `js/`. +- Keep production implementation header-only under `include/`; browser resources live in `js/`. - Prefer standard-library facilities and explicit ownership. Keep public headers ODR-safe (`inline`/templates as appropriate). - Unit tests are named `const Scenario` objects whose `given`/`when`/`then` sections are lambdas, checked with `require`/`check` (`test/unit/Bdd.hpp`), and use deterministic mocks. - Jasmine specs are the project `test/web/suite/`, built by esbuild-wasm and run by `wf test` under the locked `jasmine-core` (installed from the local registry by `WebSuiteInstall`); `webtest` is the `webfront-wf` driver plus the C++ callbacks of the specs. The specs tell C++ they are done (`specsFinished`), the process status is that of `wf test` (or 1 when C++ did not observe every call), and the CTest case has a timeout. The registry the suite installs from is built by `wf run test-registry` (the `TestRegistry` case), from the packages that configure downloaded. diff --git a/README.fr.md b/README.fr.md index a79202f7..71fe0b4c 100644 --- a/README.fr.md +++ b/README.fr.md @@ -456,6 +456,7 @@ L'installation de CMake elle-même ne demande pas de droits root. Répétez l'ex - Les appels JavaScript vers C++ renvoient toujours des Promises. En C++, `ui.jsFunction(name)(...)` est sans retour ; `ui.jsFunction(name)(...)` renvoie un `std::future`. Fonction absente, exception, réponse mal formée et déconnexion font échouer l'appel typé. Les futures et Promises n'exposent pas d'annulation ; les senders typés proposent une annulation locale. - Le pont transporte scalaires, chaînes, tuples, tableaux numériques typés, bitsets et listes homogènes de valeurs composées prises en charge. Il ne transporte pas d'objets arbitraires. Chaînes et messages sont bornés par la politique de taille (64 Mio par défaut) ; à partir de 65 536 octets, les chaînes utilisent l'encodage long. - L'environnement de développement et l'accès aux fichiers du projet sont destinés au code local de confiance, sans sandbox. Seuls les paquets compatibles navigateur sont pris en charge ; ni scripts d'installation ni extensions natives ne sont exécutés. `wf check` vérifie les types séparément de la compilation. +- Le [pseudo-terminal natif](docs/PTY.md) relie un programme choisi par l’application à xterm.js sous Linux, macOS et Windows, après activation explicite. - L'adaptateur optionnel [`@webfront/react`](docs/REACT.md) apporte stores C++ avec regroupement des mises à jour et îlots React. `WebFrontLifeReact` montre un panneau C++ dans React ; son archive est préparée localement pour publication au registre. - Linux embarqué dispose d'une CI ARM64 et de preuves sur Orin Nano. Les autres cartes, cibles sans OS et microcontrôleurs ne sont pas qualifiés globalement. Le transport local ne fournit ni TLS ni authentification client ; un accès distant demande une conception de sécurité propre à l'application. - Packaging, accessibilité et déploiement des moteurs natifs restent propres au produit. L'[état du projet](docs/PROJECT_STATUS.md) fait référence pour les validations et limites ; l'[historique](docs/CHANGELOG.md) décrit les migrations et ruptures de compatibilité. diff --git a/README.md b/README.md index fea5ac0f..33bbc334 100644 --- a/README.md +++ b/README.md @@ -524,6 +524,7 @@ CI exercises C++ and native-browser paths on Windows, macOS and Linux. Extended - JavaScript calls to C++ always return Promises. C++ `ui.jsFunction(name)(...)` is fire-and-forget; `ui.jsFunction(name)(...)` returns `std::future`. Missing functions, exceptions, malformed replies and disconnects fail the typed call. - The binary bridge supports scalars, strings, tuples, numeric typed arrays, packed bitsets and homogeneous lists of supported compound values. Arbitrary objects do not cross it. Strings and messages are bounded by the message-size policy (64 MiB by default); strings of 65,536 bytes or more use the long-string encoding. See [the bridge contract](docs/adr/ADR-003-protocole-binaire-et-bornes.md). - Development project access is explicit and intended for trusted local code. Downloaded tools run with the application's bridge authority, and script permissions frame only the `context` API: neither is a sandbox. Only packages that run in a browser are supported; installation scripts and native add-ons are not executed. Builds transform TypeScript without type checking; `wf check` type-checks with the compiler the project locks. +- An opt-in [native pseudoterminal](docs/PTY.md) connects an application-selected program to xterm.js on Linux, macOS and Windows. - The optional [`@webfront/react` adapter](docs/REACT.md) supplies coalesced C++ stores and empty React islands. `WebFrontLifeReact` demonstrates a C++ panel within the Game of Life React UI; its package archive is prepared locally for registry publication. - Embedded Linux has ARM64 CI coverage and specific Orin Nano board evidence; other boards, bare-metal targets and microcontrollers are not generally qualified. Check C++23, memory, networking and browser requirements for your target. The default local transport supplies neither TLS nor client authentication; remote deployment needs an application-specific security design. - Packaging, accessibility and native-engine deployment still need application-specific work. The optional [`ui.document()` API](docs/DOM.md) provides DOM islands, automatically batched writes, event callbacks and grouped sender reads. See [project status](docs/PROJECT_STATUS.md) for known limitations. diff --git a/cmake/BoingCuda.cmake b/cmake/BoingCuda.cmake index 53f73e16..6f9bee17 100644 --- a/cmake/BoingCuda.cmake +++ b/cmake/BoingCuda.cmake @@ -6,6 +6,7 @@ # default one, CMAKE_CUDA_HOST_COMPILER (or the CUDAHOSTCXX environment variable) names another. set(WEBFRONT_HOST_LOOP_CUDA "AUTO" CACHE STRING "CUDA renderer of the host-loop example: AUTO (when a working toolkit is found), ON or OFF") set_property(CACHE WEBFRONT_HOST_LOOP_CUDA PROPERTY STRINGS AUTO ON OFF) +set(_WEBFRONT_BOING_CUDA_DIR "${CMAKE_CURRENT_LIST_DIR}") # A macro: enable_language() must run in the scope of the top-level CMakeLists.txt, above every directory whose # targets link the CUDA unit. Defines WebFront_boing, which a target computing the scene links: nothing on a CPU-only @@ -15,6 +16,11 @@ macro(webfront_enable_host_loop_cuda) message(FATAL_ERROR "WEBFRONT_HOST_LOOP_CUDA must be AUTO, ON or OFF, not '${WEBFRONT_HOST_LOOP_CUDA}'") endif() set(WEBFRONT_HOST_LOOP_CUDA_ENABLED OFF) + # Record the choice before enable_language initializes its own compiler-dependent default. + set(_webfront_cuda_architectures_explicit FALSE) + if(DEFINED CMAKE_CUDA_ARCHITECTURES OR (DEFINED ENV{CUDAARCHS} AND NOT "$ENV{CUDAARCHS}" STREQUAL "")) + set(_webfront_cuda_architectures_explicit TRUE) + endif() if(WEBFRONT_HOST_LOOP_CUDA STREQUAL "ON") enable_language(CUDA) set(WEBFRONT_HOST_LOOP_CUDA_ENABLED ON) @@ -27,6 +33,10 @@ macro(webfront_enable_host_loop_cuda) endif() endif() if(WEBFRONT_HOST_LOOP_CUDA_ENABLED) + if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA") + include("${_WEBFRONT_BOING_CUDA_DIR}/BoingCudaArchitectures.cmake") + webfront_cuda_select_default("${_webfront_cuda_architectures_explicit}" "${CMAKE_CUDA_COMPILER}") + endif() message(STATUS "Host-loop example: CUDA ${CMAKE_CUDA_COMPILER_VERSION} renderer enabled (${CMAKE_CUDA_COMPILER})") else() message(STATUS "Host-loop example: CPU renderer only (WEBFRONT_HOST_LOOP_CUDA=${WEBFRONT_HOST_LOOP_CUDA}, no working CUDA compiler)") diff --git a/cmake/BoingCudaArchitectures.cmake b/cmake/BoingCudaArchitectures.cmake new file mode 100644 index 00000000..16e4e423 --- /dev/null +++ b/cmake/BoingCudaArchitectures.cmake @@ -0,0 +1,51 @@ +# Select only installed GPUs for which nvcc can emit native machine code. A matching cubin avoids depending on the +# driver's PTX compiler, which may be older than the toolkit. Empty means detection could not make a safe choice. +function(webfront_cuda_native_architectures devices compiler_codes output) + string(REPLACE "\r" "" devices "${devices}") + string(REPLACE "\n" ";" devices "${devices}") + string(REPLACE "\r" "" compiler_codes "${compiler_codes}") + string(REPLACE "\n" ";" compiler_codes "${compiler_codes}") + set(architectures) + foreach(device IN LISTS devices) + string(STRIP "${device}" device) + if(device MATCHES "^([0-9]+)\\.([0-9]+)$") + set(arch "${CMAKE_MATCH_1}${CMAKE_MATCH_2}") + if("sm_${arch}" IN_LIST compiler_codes) + list(APPEND architectures "${arch}") + endif() + endif() + endforeach() + list(REMOVE_DUPLICATES architectures) + set(${output} "${architectures}" PARENT_SCOPE) +endfunction() + +function(webfront_cuda_detect_native compiler output) + set(${output} "" PARENT_SCOPE) + if(CMAKE_CROSSCOMPILING) + return() + endif() + find_program(_webfront_nvidia_smi NAMES nvidia-smi) + if(NOT _webfront_nvidia_smi) + return() + endif() + execute_process(COMMAND "${_webfront_nvidia_smi}" --query-gpu=compute_cap --format=csv,noheader + RESULT_VARIABLE device_result OUTPUT_VARIABLE devices ERROR_QUIET TIMEOUT 5) + execute_process(COMMAND "${compiler}" --list-gpu-code + RESULT_VARIABLE compiler_result OUTPUT_VARIABLE codes ERROR_QUIET TIMEOUT 5) + if(device_result STREQUAL "0" AND compiler_result STREQUAL "0") + webfront_cuda_native_architectures("${devices}" "${codes}" architectures) + set(${output} "${architectures}" PARENT_SCOPE) + endif() +endfunction() + +function(webfront_cuda_select_default explicit_choice compiler) + if(explicit_choice OR CMAKE_CROSSCOMPILING) + return() + endif() + webfront_cuda_detect_native("${compiler}" architectures) + if(architectures) + set(CMAKE_CUDA_ARCHITECTURES "${architectures}" CACHE STRING "CUDA architectures" FORCE) + set(CMAKE_CUDA_ARCHITECTURES "${architectures}" PARENT_SCOPE) + message(STATUS "Host-loop example: native CUDA architectures ${architectures}") + endif() +endfunction() diff --git a/cmake/Frontends.cmake b/cmake/Frontends.cmake index e57bdf28..158a1491 100644 --- a/cmake/Frontends.cmake +++ b/cmake/Frontends.cmake @@ -9,7 +9,7 @@ macro(_webfront_load_frontends) get_property(WEBFRONT_FRONTEND_REGISTRY GLOBAL PROPERTY WEBFRONT_FRONTEND_REGISTRY) endif() foreach(_wf_entry IN LISTS WEBFRONT_FRONTEND_REGISTRY) - foreach(_wf_field OPTION POLICY DESCRIPTION SUPPORT SUPPORT_FILE SETUP TEST_SETUP TEST_NAME TEST_TIMEOUT PLATFORMS TEST_PLATFORMS XVFB_LINUX NATIVE) + foreach(_wf_field OPTION POLICY DESCRIPTION SUPPORT SUPPORT_FILE SETUP TEST_SETUP TEST_NAME TEST_TIMEOUT PLATFORMS TEST_PLATFORMS XVFB_LINUX NATIVE STARTUP_TRACE) get_property(WEBFRONT_FRONTEND_${_wf_entry}_${_wf_field} GLOBAL PROPERTY WEBFRONT_FRONTEND_${_wf_entry}_${_wf_field}) endforeach() @@ -36,7 +36,7 @@ function(webfront_register_frontend name) if(NOT "${name}" MATCHES "^[A-Za-z_][A-Za-z0-9_]*$") message(FATAL_ERROR "Frontend name '${name}' must be a C++ identifier") endif() - cmake_parse_arguments(PARSE_ARGV 1 ARG "XVFB_LINUX;ALWAYS_AVAILABLE;NATIVE" "OPTION;POLICY;DESCRIPTION;SUPPORT;SETUP;TEST_SETUP;TEST_NAME;TEST_TIMEOUT" "PLATFORMS;TEST_PLATFORMS") + cmake_parse_arguments(PARSE_ARGV 1 ARG "XVFB_LINUX;ALWAYS_AVAILABLE;NATIVE;STARTUP_TRACE" "OPTION;POLICY;DESCRIPTION;SUPPORT;SETUP;TEST_SETUP;TEST_NAME;TEST_TIMEOUT" "PLATFORMS;TEST_PLATFORMS") if(name IN_LIST WEBFRONT_FRONTEND_REGISTRY) message(FATAL_ERROR "Frontend '${name}' is already registered") endif() @@ -98,11 +98,14 @@ function(webfront_register_frontend name) if(ARG_NATIVE) message(FATAL_ERROR "Frontend '${name}' cannot use NATIVE without OPTION") endif() + if(ARG_STARTUP_TRACE) + message(FATAL_ERROR "Frontend '${name}' cannot use STARTUP_TRACE without OPTION") + endif() endif() list(APPEND WEBFRONT_FRONTEND_REGISTRY "${name}") set_property(GLOBAL PROPERTY WEBFRONT_FRONTEND_REGISTRY "${WEBFRONT_FRONTEND_REGISTRY}") set(WEBFRONT_FRONTEND_REGISTRY "${WEBFRONT_FRONTEND_REGISTRY}" PARENT_SCOPE) - foreach(field OPTION POLICY DESCRIPTION SUPPORT SUPPORT_FILE SETUP TEST_SETUP TEST_NAME TEST_TIMEOUT PLATFORMS TEST_PLATFORMS XVFB_LINUX NATIVE) + foreach(field OPTION POLICY DESCRIPTION SUPPORT SUPPORT_FILE SETUP TEST_SETUP TEST_NAME TEST_TIMEOUT PLATFORMS TEST_PLATFORMS XVFB_LINUX NATIVE STARTUP_TRACE) set_property(GLOBAL PROPERTY WEBFRONT_FRONTEND_${name}_${field} "${ARG_${field}}") set(WEBFRONT_FRONTEND_${name}_${field} "${ARG_${field}}" PARENT_SCOPE) endforeach() @@ -184,19 +187,19 @@ endfunction() webfront_register_frontend(DefaultBrowser ALWAYS_AVAILABLE) webfront_register_frontend(WebView2 - NATIVE OPTION WEBFRONT_EMBED_WEBVIEW2 POLICY strict + NATIVE STARTUP_TRACE OPTION WEBFRONT_EMBED_WEBVIEW2 POLICY strict DESCRIPTION "Download the pinned WebView2 SDK and link its static loader (Windows only)" PLATFORMS Windows SUPPORT WebView2Support TEST_PLATFORMS Windows TEST_NAME WebFrontWebView2Integration TEST_TIMEOUT 90 TEST_SETUP webfront_add_webview2_tests) webfront_register_frontend(WKWebView - NATIVE OPTION WEBFRONT_EMBED_WKWEBVIEW POLICY strict + NATIVE STARTUP_TRACE OPTION WEBFRONT_EMBED_WKWEBVIEW POLICY strict DESCRIPTION "Link the system Cocoa and WebKit frameworks for WKWebViewFrontend (macOS 13.3+ only)" PLATFORMS Darwin SUPPORT WKWebViewSupport TEST_PLATFORMS Darwin TEST_NAME WebFrontWKWebViewIntegration TEST_TIMEOUT 90 TEST_SETUP webfront_add_wkwebview_tests) webfront_register_frontend(WebKitGTK - NATIVE OPTION WEBFRONT_EMBED_WEBKITGTK POLICY strict + NATIVE STARTUP_TRACE OPTION WEBFRONT_EMBED_WEBKITGTK POLICY strict DESCRIPTION "Enable the system WebKitGTK 6.0 embedded frontend (Linux only)" PLATFORMS Linux SUPPORT WebKitGTKSupport TEST_PLATFORMS Linux TEST_NAME WebFrontWebKitGTKIntegration TEST_TIMEOUT 90 XVFB_LINUX @@ -448,6 +451,25 @@ function(webfront_add_browser_tests target frontend assets_directory lifecycle_t webfront_set_browser_test_properties("${lifecycle_name}" "${assets_directory}" "${WEBFRONT_FRONTEND_${frontend}_TEST_TIMEOUT}") endforeach() + # Start-up time of the native windows, cold and warm (#611), only for a frontend that declared STARTUP_TRACE: the + # script reads the `WebFront startup: window shown at ms` milestone that WEBFRONT_STARTUP_TRACE=1 prints. + if(WEBFRONT_FRONTEND_${frontend}_STARTUP_TRACE) + foreach(temperature cold warm) + set(startup_name "${frontend}StartupTime-${temperature}") + set(startup_limit 10000) + if(temperature STREQUAL "warm") + set(startup_limit 5000) + endif() + add_test(NAME ${startup_name} COMMAND "${CMAKE_COMMAND}" + "-DPROGRAM=${lifecycle_command}" "-DWORK_DIRECTORY=${assets_directory}" + "-DSCRATCH=${CMAKE_CURRENT_BINARY_DIR}/startup-${frontend}-${temperature}" + -DTEMPERATURE=${temperature} -DLIMIT_MS=${startup_limit} + -P "${PROJECT_SOURCE_DIR}/test/cmake/RunStartupTime.cmake") + list(APPEND shared_tests "${startup_name}") + webfront_set_browser_test_properties("${startup_name}" "${assets_directory}" 180) + set_property(TEST ${startup_name} APPEND PROPERTY LABELS startup) + endforeach() + endif() if(NOT ARG_SKIP_JASMINE) set(name "${WEBFRONT_FRONTEND_${frontend}_TEST_NAME}") add_test(NAME ${name} COMMAND ${command} ${ARG_ARGUMENTS}) diff --git a/cmake/WKWebViewSupport.cmake b/cmake/WKWebViewSupport.cmake index 6efe1c01..7daf2dbc 100644 --- a/cmake/WKWebViewSupport.cmake +++ b/cmake/WKWebViewSupport.cmake @@ -18,7 +18,7 @@ function(webfront_add_wkwebview_tests) add_executable(wkwebview_lifecycle "${webtest_source_dir}/WKWebViewLifecycle.cpp" "${webtest_source_dir}/WKWebViewHeaderConsumer.cpp") target_link_libraries(wkwebview_lifecycle PRIVATE WebFront WebFront_warnings WebFront_options) - foreach(mode repeated-show main-thread native-close quit navigation-diagnostic startup-timeout settings hidden-scheduling redirect-policy missing-response committed-navigation agent-application download choose-file cancel-choose replaced-download choose-in-blank choose-in-srcdoc close-with-open-panel close-with-save-panel script-dialogs close-with-script-dialog sandboxed-script-dialog) + foreach(mode repeated-show main-thread native-close quit navigation-diagnostic startup-timeout settings translucent-background hidden-scheduling redirect-policy missing-response committed-navigation agent-application download choose-file cancel-choose replaced-download choose-in-blank choose-in-srcdoc close-with-open-panel close-with-save-panel script-dialogs close-with-script-dialog sandboxed-script-dialog load-reveal present-timeout) add_test(NAME WKWebViewLifecycle-${mode} COMMAND wkwebview_lifecycle ${mode}) webfront_set_browser_test_properties("WKWebViewLifecycle-${mode}" "${webtest_source_dir}" 90) endforeach() diff --git a/cmake/WebKitGTKSupport.cmake b/cmake/WebKitGTKSupport.cmake index 3add3cee..d84141a7 100644 --- a/cmake/WebKitGTKSupport.cmake +++ b/cmake/WebKitGTKSupport.cmake @@ -28,7 +28,7 @@ function(webfront_add_webkitgtk_tests) target_link_libraries(webkitgtk_lifecycle PRIVATE WebFront_test_hardening WebFront WebFront_warnings WebFront_options) add_dependencies(webtest webkitgtk_lifecycle) webfront_find_xvfb(display_runner) - foreach(mode sandbox-environment sandbox-recheck no-display worker-thread native-close repeated-show http-error pre-run-failure poll-failure profile-permissions window-title download download-user-dir choose-file cancel-choose close-with-dialog script-dialogs close-with-script-dialog) + foreach(mode sandbox-environment sandbox-recheck no-display worker-thread native-close repeated-show http-error pre-run-failure poll-failure profile-permissions window-title download download-user-dir choose-file cancel-choose close-with-dialog script-dialogs close-with-script-dialog first-frame present-timeout media-scoped) if(mode MATCHES "^(no-display|worker-thread|pre-run-failure|profile-permissions)$") add_test(NAME WebKitGTKAdapter-${mode} COMMAND webkitgtk_lifecycle ${mode}) elseif(display_runner) diff --git a/cmake/WebView2Support.cmake b/cmake/WebView2Support.cmake index 5f7dd632..2229dbd1 100644 --- a/cmake/WebView2Support.cmake +++ b/cmake/WebView2Support.cmake @@ -55,7 +55,7 @@ target_include_directories(WebFront SYSTEM INTERFACE "${WebView2SDK_SOURCE_DIR}/ target_compile_definitions(WebFront INTERFACE WEBFRONT_EMBED_WEBVIEW2) target_link_libraries(WebFront INTERFACE "${WebView2SDK_SOURCE_DIR}/build/native/${_webview2_arch}/WebView2LoaderStatic.lib" - ole32 oleaut32 user32 shell32 shlwapi version) + ole32 oleaut32 user32 gdi32 shell32 shlwapi version) # Register lifecycle coverage once, alongside the shared Jasmine runner; paths are module-relative. function(webfront_add_webview2_tests) @@ -66,7 +66,7 @@ function(webfront_add_webview2_tests) target_link_libraries(webview2_lifecycle PRIVATE WebFront WebFront_warnings WebFront_options) foreach(mode repeated-show native-early-close navigation-diagnostic mta missing-runtime closed-startup-timeout failed-startup-timeout late-navigation-failure runtime-ready - file-choose file-cancel file-download script-dialogs) + file-choose file-cancel file-download script-dialogs first-frame present-timeout) add_test(NAME WebView2Lifecycle-${mode} COMMAND webview2_lifecycle ${mode}) webfront_set_browser_test_properties("WebView2Lifecycle-${mode}" "${webtest_source_dir}" 45) endforeach() diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index bc4d781c..58fcc173 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -10,6 +10,34 @@ these entries stays in the GitHub releases and the Git history. ## Unreleased +## [1.1.0] - 2026-11-20 + +WebFront 1.1 ships with developer environment 1.0.1. It adds POST routes with a bounded body, application-selected programs +in a native pseudoterminal, and a faster, less flashy start of the native windows. No breaking change. + +### Added +- Answer `POST` on a dynamic route that opts in with `http::RouteOptions::postBodyLimit`: the body, bounded by `Content-Length`, reaches the handler as `RouteRequest::body`; `Response::accepted` (202) and `Response::unauthorized` (401) have their reason phrases (#619, `docs/HTTP_ASSETS.md`). +- CEF supports `WindowOptions::background` and shows its window when the first document has loaded or after one second (#611, `docs/FRONTENDS.md`). +- Print a hint on standard error when the development file system serves a stylesheet whose `font-family` lists four or more costly families (#611, `docs/WEBKITGTK.md`). +- Run the start-up time of the native windows, cold and warm (cold is fully cold on Linux only), as `StartupTime-cold` and `-warm` (label `startup`) with generous limits, timed from the start of the program so that the frontend's initialization counts (#611, `docs/WEBKITGTK.md`). +- Run application-selected programs in a native pseudoterminal with an optional xterm.js page adapter and replay across reloads (#613, `docs/PTY.md`). +- Skip GStreamer's initialization, and its plugin scan, in WebKitGTK for an application whose pages never use audio or video, with `WindowOptions::media = false`; the default keeps media (#611, `docs/WEBKITGTK.md`). +- WKWebView supports `WindowOptions::background`, translucent colours included, and `WEBFRONT_STARTUP_TRACE=1` (#611, `docs/WKWEBVIEW.md`). +- WebView2 supports `WindowOptions::background` and `WEBFRONT_STARTUP_TRACE=1` (#611, `docs/WEBVIEW2.md`). +- Choose the colour of the WebKitGTK view under the page with `WindowOptions::background` (WebKitGTK; the other embedded frontends are listed here), and read the start-up milestones of a WebKitGTK view with `WEBFRONT_STARTUP_TRACE=1` (#611, `docs/WEBKITGTK.md`). + +### Changed +- Reveal the WKWebView window when the document has loaded or after one second (#611, `docs/WKWEBVIEW.md`). +- Reveal the WebView2 window after the first frame or one second (#611, `docs/WEBVIEW2.md`). +- Show the WebKitGTK window when the page reports its first frame, or when a one-second timer fires, even if the page has not painted, instead of at once; the embedded pages, the starter and the examples use the cheap `sans-serif` and `monospace` font stacks (#611, `docs/WEBKITGTK.md`). + +### Fixed +- Accept HTTP request headers with optional spaces or tabs after the colon, tabs in values, and empty values (#621). +- Read an obsolete line fold in a request header as one space (RFC 9112, section 5.2), not as the two lines glued together: a `Content-Length` folded as `1` and `0` was read as `10` (#619). +- Keep the input focus of the developer terminal after a click on the page around it (title, notice, blank areas) while the terminal has the window, selection and controls excepted (#608). +- Remove the white flash of an embedded view between the developer environment's bootstrap page and the project's page, by giving the window the environment's dark colour (`#141821`) when the application sets none; on macOS the view then no longer paints its own white behind it (#611, `docs/WKWEBVIEW.md`). +- Select detected GPU architectures supported by nvcc by default for the host-loop CUDA renderer (`docs/HOST_LOOP_EXAMPLE.md`). + ## [1.0.0] - 2026-11-17 WebFront 1.0 ships with developer environment 1.0.0. This release adds host-loop integration, developer tools and @@ -231,7 +259,8 @@ Coroutines and the opt-in developer environment. One **breaking** change to the - Fail decoding when a bridge integer is out of the requested C++ range, instead of invoking undefined behavior. -[Unreleased]: https://github.com/ambroise-leclerc/WebFront/compare/v1.0.0...HEAD +[Unreleased]: https://github.com/ambroise-leclerc/WebFront/compare/v1.1.0...HEAD +[1.1.0]: https://github.com/ambroise-leclerc/WebFront/compare/v1.0.0...v1.1.0 [1.0.0]: https://github.com/ambroise-leclerc/WebFront/compare/v0.9.0...v1.0.0 [0.9.0]: https://github.com/ambroise-leclerc/WebFront/compare/v0.8.0...v0.9.0 [0.8.0]: https://github.com/ambroise-leclerc/WebFront/compare/v0.7.0...v0.8.0 diff --git a/docs/DEVELOPER_ENVIRONMENT.md b/docs/DEVELOPER_ENVIRONMENT.md index 56f10f62..7b6ac240 100644 --- a/docs/DEVELOPER_ENVIRONMENT.md +++ b/docs/DEVELOPER_ENVIRONMENT.md @@ -79,8 +79,8 @@ Each published version is immutable: 0.3.0 introduced the packed-bitset Life sta manifest, `wf restore`, `wf run`, `wf exec`, `wf check` and the complete terminal, and 0.6.0 `wf build`, `wf dev` and `wf test`. The default configuration is generated in `include/webfront/system/DeveloperReleaseData.hpp`; it contains -an exact versioned environment URL and the trusted digest. The 1.0.0 release pin selects -`https://dist.webfront.fr/developer/1.0.0/environment.tgz` (ADR-021). The deployed archive, CORS headers and public +an exact versioned environment URL and the trusted digest. The 1.0.1 release pin selects +`https://dist.webfront.fr/developer/1.0.1/environment.tgz` (ADR-021). The deployed archive, CORS headers and public smoke test were verified before the pin was merged. Earlier publication gates are recorded for [0.6.6](validation/developer-0.6.6-release.md), [0.6.4](validation/developer-0.6.4-release.md) and [0.6.3](validation/developer-0.6.3-release.md). Published 0.6.2 introduced installation of the archives of `@types` packages and the manifest directory; @@ -727,7 +727,8 @@ above). Rows before 0.9 were reconstructed from the header of each tag; 0.4.0 pr | Library | Environment | Minimum api | | --- | --- | --- | -| unreleased | 1.0.0 | 1 | +| unreleased | 1.0.1 | 1 | +| 1.1.0 | 1.0.1 | 1 | | 1.0.0 | 1.0.0 | 1 | | 0.9.0 | 0.9.0 | 1 | | 0.8.0 | 0.6.3 | 1 | diff --git a/docs/FRONTENDS.md b/docs/FRONTENDS.md index bf4dace3..3d0b556d 100644 --- a/docs/FRONTENDS.md +++ b/docs/FRONTENDS.md @@ -68,7 +68,10 @@ embedded frontends (WebKitGTK, CEF, WebView2, WKWebView); the system browser ign executable's name ("WebFront" if it cannot be determined), and a non-positive size selects 1200 x 800. `BasicWF` passes the options to a frontend that provides `open(address, port, file, policy, window)`; WebView2 and WKWebView also accept them in `WebView2Options::window` and `WKWebViewOptions::window`. The title is fixed at creation: following -`document.title` is not implemented. +`document.title` is not implemented. `background` colours the view under the page and the window, and every embedded +frontend shows its window when the first document has loaded or after one second (CEF and WKWebView at the document's load, WebKitGTK +and WebView2 at their first frame), so that the window does not appear blank; CEF applies the colour to the browser +and to its window, as an opaque colour whatever non-zero alpha is given (CEF accepts only 0x00 or 0xFF; `#rrggbb00` leaves its default), and `media` concerns WebKitGTK only. ## Content policy @@ -188,6 +191,7 @@ engines show it only after a user gesture on the page); its wiring is implemente | `TEST_NAME`, `TEST_TIMEOUT` | Shared Jasmine CTest name and positive timeout in seconds. | | `TEST_SETUP` | Optional function adding engine-specific tests. It receives the explicit list of registered shared tests (including Jasmine), and runs even if missing Xvfb prevents shared registration; the module decides which additional tests need a display. | | `XVFB_LINUX` | Wrap the shared tests with Xvfb on Linux. Other registered test platforms run without that wrapper. | +| `STARTUP_TRACE` | The frontend prints the `WebFront startup: window shown at ms` milestone on standard error when `WEBFRONT_STARTUP_TRACE=1` (see `WKWebView.hpp`). Only then are `StartupTime-cold` and `-warm` registered; a frontend without it (CEF, a third party) gets no start-up test and no failing standard tier. Requires `OPTION`. | | `ALWAYS_AVAILABLE` | Declare a frontend without an availability option. Defaults to `POLICY lenient`, rejects `POLICY strict`, and cannot supply engine or test fields. | The selectors, cache choices, diagnostics, dependency loading and CTest registration use this entry. The optional `SETUP` and `TEST_SETUP` functions are checked immediately after the enabled support module is loaded. diff --git a/docs/HOST_LOOP_EXAMPLE.md b/docs/HOST_LOOP_EXAMPLE.md index 20664605..9e07071d 100644 --- a/docs/HOST_LOOP_EXAMPLE.md +++ b/docs/HOST_LOOP_EXAMPLE.md @@ -52,6 +52,15 @@ working CUDA compiler, and the example is complete without one. `ON` makes a mis `.cu` unit compiled at C++17, and `CMAKE_CUDA_HOST_COMPILER` names another host compiler when nvcc refuses the default one. At run time the engine is offered only when a device answers. +On a fresh native build, CMake selects installed NVIDIA GPUs that `nvcc` supports and embeds native code for them. This +avoids depending on the driver's PTX compiler, which may be older than the toolkit. If detection is unavailable, CMake +keeps the compiler's default. Explicit `CMAKE_CUDA_ARCHITECTURES` and `CUDAARCHS` choices take precedence; select all +target architectures for a distribution or cross-build. A previous build retains its cached choice: remove that cache +entry to redetect the local GPU. If the redetection fails (`nvidia-smi` unavailable), CMake keeps no architecture in an +already configured build directory: give `CMAKE_CUDA_ARCHITECTURES` explicitly or start from a fresh build directory +before generating `WebFront_boing_cuda`. With a Visual Studio generator, rebuild `WebFront_boing_cuda` after changing it, since +MSBuild may otherwise retain the previous CUDA object. + **The window.** With the platform's native engine in the build (WebKitGTK on Linux, autodetected), the example opens a native window; otherwise, or with `--browser`, it opens the system browser. On a Jetson Orin (L4T R39.2.1, Ubuntu 24.04) the native window opens with no change to the system: no AppArmor profile, no sysctl, no package. diff --git a/docs/HTTP_ASSETS.md b/docs/HTTP_ASSETS.md index 9d79cba2..1b30b0f6 100644 --- a/docs/HTTP_ASSETS.md +++ b/docs/HTTP_ASSETS.md @@ -48,6 +48,21 @@ header that could split the response or that the server owns (`Content-Length`, 500. The registration handle removes the route when destroyed; a request already running keeps its handler. The binding of a request to a connection (#469) is not part of this mechanism yet. +`app.addRoute(prefix, handler, http::RouteOptions{.postBodyLimit = n})` also answers `POST` (#619), for a small request +such as a JSON-RPC call: the body, announced by `Content-Length` and at most `n` bytes, is read whole before the handler +runs and reaches it as `RouteRequest::body`. `Expect: 100-continue` gets `100 Continue` first. The server refuses, without +calling the handler, a `POST` without `Content-Length` (411), with a `Transfer-Encoding` (501: no chunked bodies), with a +malformed or contradictory length (400; spaces around the value and a list of equal lengths such as `5, 5` are accepted) or a longer body (413); a connection that ends before the announced length is +closed without an answer. `100 Continue` goes only to an HTTP/1.1 client whose `Expect` lists `100-continue` (alone or among other +comma-separated tokens, compared without case), and +not when the body is already there or the request is refused. Such a route lists `POST` in the `Allow` header of its 405. +There is still one request per connection, and no check of the origin of the request: a route that changes state verifies +it, with a token or the `Origin` header. + +Limits: the server has no timeout on reading the headers or the body, so a slow client holds its connection and the +bytes received so far (at most `n`); size `n` for the smallest request the route needs. A refusal sent while the client +is still sending its body can reach it as a connection reset instead of the status, since the unread body is not drained. + ## Byte ranges (#455) An unencoded file of known size, from any provider, is served by ranges (RFC 9110 §14) and says so with diff --git a/docs/PROJECT_STATUS.md b/docs/PROJECT_STATUS.md index 67a3a880..53821250 100644 --- a/docs/PROJECT_STATUS.md +++ b/docs/PROJECT_STATUS.md @@ -27,6 +27,7 @@ WebFront is a header-only C++23 HTTP/WebSocket core plus a standalone developer system browser, `app.requestClose()` from another thread, or `webfront::UIThread` where the frontend accepts a secondary thread (WebView2); a host loop cannot share the main thread with an embedded window. See [host integration](HOST_INTEGRATION.md). +- **Native pseudoterminals (opt-in).** `webfront::Pty` uses a Unix PTY on Linux and macOS or ConPTY on Windows 10 version 1809 and later. The page adapter requires a loopback bind and the application’s own browser origin. See the [PTY guide and standalone example](PTY.md). - **Developer environment.** `NativeApp::bootstrap("developer")` loads the verified, pinned environment selected by `DeveloperReleaseData.hpp`. Its terminal provides `wf init`, `create`, `install`, `restore`, `run`, `exec`, `check`, `test`, `build`, `dev`, `preview`, `embed`, `list`, `why`, `info` and `help`, beside the terminal's own read-only `ls`, `cat`, `tree` and `mounts` (ADR-023). The manifest and lock describe @@ -40,7 +41,7 @@ WebFront is a header-only C++23 HTTP/WebSocket core plus a standalone developer Native-engine deployment remains application work. The [README walkthrough](../README.md) covers the console, developer and embedded Game of Life stages; Hello World and the host loop (`examples/host-loop/`, a Boing Ball ray-traced by the host on the CPU or with optional CUDA; see - [the host-loop example](HOST_LOOP_EXAMPLE.md) for its measurements and limits) are the other public examples. + [the host-loop example](HOST_LOOP_EXAMPLE.md) for its measurements and limits) are also in the default build. - **Developer automation (opt-in).** `webfront-agent` provides local stdio MCP and a JSON CLI for an explicitly launched developer window. Native grants select check/build/test/preview, bounded inspection and semantic actions. [Automation](AUTOMATION.md) documents provisioning, diff --git a/docs/PTY.md b/docs/PTY.md new file mode 100644 index 00000000..5a6a8adb --- /dev/null +++ b/docs/PTY.md @@ -0,0 +1,46 @@ +# Native pseudoterminals + +Include `` to run a program in a native terminal from C++. The child receives the requested argument vector, working directory, environment and initial terminal dimensions. Linux and macOS use a Unix PTY. Windows uses ConPTY, available since Windows 10 version 1809 and Windows Server 2019. [Microsoft's ConPTY documentation](https://learn.microsoft.com/en-us/windows/console/creating-a-pseudoconsole-session) + +```cpp +webfront::Pty terminal({ + .argv = {"sh", "-i"}, + .directory = "/path/to/project", + .environment = {{"PATH", "/usr/bin:/bin"}}, + .size = {100, 32} +}); +``` + +Use UTF-8 strings for arguments and environment entries. The environment comes from `PtyOptions::environment`, with defaults for `TERM` (`xterm-256color`), `COLORTERM` (`truecolor`) and Windows `SystemRoot`. Supply any other variables the program needs, such as `HOME`, `USERPROFILE` or `PATH`. Relative paths are resolved against the child's directory. Bare executable names are searched in the supplied `PATH` or, when it is absent, in `/usr/bin:/bin` on Unix and the system directory on Windows. Windows also resolves `.cmd` and `.bat` shims and runs them through the system `cmd.exe`. Paths and arguments passed to batch scripts must omit double quotes, percent signs and line breaks. + +- `write(bytes)` queues a whole chunk if there is room. It returns `false` immediately when the 64 KiB queue is full, the chunk exceeds capacity or the terminal is closing. +- `read(cursor, stopToken)` waits for data, exit, cancellation or hangup. `tryRead(cursor)` takes a snapshot without waiting for terminal I/O. Start at cursor zero and use the returned `next` for the following read. Each snapshot contains at most 16 KiB. `truncated` means the cursor fell behind the latest 1 MiB of retained output. The final snapshot carries the exit code. +- `resize({columns, rows})` schedules a resize on the terminal worker. Consecutive requests may be coalesced. +- `hangUp()` wakes readers and requests cleanup. `exitCode()` becomes available after cleanup. Destruction joins the worker. On Unix, cleanup signals the child and the foreground process group with SIGHUP and then escalates to SIGKILL. The host must leave the PTY child available for WebFront to reap. Cleanup also looks for remaining processes in the same session, including after the session leader exits. A process that creates a separate session may outlive it. On Linux with pidfds, cleanup uses a stable reference when signalling a member of a secondary group. Other Unix configurations check session and process group membership immediately before signalling by PID. On Windows, a job object terminates the entire process tree and ConPTY is closed. Ctrl+C follows the child console mode and the Windows control-handler policy. If the host was launched with Ctrl+C ignored, a child can inherit that setting. The example enables normal processing for its own process with `SetConsoleCtrlHandler(nullptr, FALSE)` before launch. + +After natural exit, the worker drains terminal output to EOF or until a three-second deadline when another process holds the terminal open. Unix waits on the terminal and a wake pipe, with a 250 ms backstop for child exit. Windows checks its output pipe every 40 ms while idle and every 10 ms when input is pending or final output is draining. ConPTY keeps accepting output from descendants until its job empties or the drainage deadline expires. The launch pipe closes on exec. On Unix, coordinate host forks that retain inherited descriptors with PTY startup. A concurrent child that keeps the writer open can cause the PTY launch to fail at the ten-second startup deadline. + +## Connect a browser page + +Set `WebFrontConfig::allowPtyPages = true` and call `webfront::registerPtyPage(app, options)` from `` before starting the server. Use a literal IPv4 loopback address or `::1` and set `contentPolicy.allowMissingOrigin = false`. Leave `allowAnyBridgeOrigin` disabled and `bridgeAllowedOrigins` empty. WebFront rejects incompatible configurations before binding. The application configures the executable, directory and environment. A dedicated worker starts the native process, so its startup wait leaves the server available. A page can open the configured session, send terminal input, resize, read output or hang up. + +Every page of that origin shares access to the registered terminal. Serve trusted content and keep the loopback port private to the local application. A local native client can supply its own `Origin` header, and forwarding the port can extend access beyond the local machine. The terminal runs with the host application's privileges. + +Bundle [the adapter](../js/pty/index.mjs) from the `@webfront/pty` package with your page and call `mount(element, {terminal, fit})` with your xterm.js `Terminal` and `FitAddon`. The adapter writes byte chunks to xterm so UTF-8 sequences can span reads. It forwards input and resizes the PTY when the container changes size. `onError` reports a rejected input or bridge failure, `onExit` receives the process status and `onTruncated` reports when some history has expired. The adapter rejects paste events that exceed the 64 KiB browser input queue, measured in UTF-8 bytes and reduced by pending input. If the native queue fills, the adapter reports the rejection and discards unsent input. The child may already have received earlier chunks. + +Each registration owns one session, opened on first attach and retained across page reloads, including after the child exits. Pass `restart: true` to `mount` to start a fresh session after the old process has finished. The old replay is discarded and pending calls for the old session are refused. A different callback name selects another application-configured session. Call `dispose()` when unmounting the adapter to stop its output requests and listeners. Call `hangUp()` to close the process. Application shutdown also closes the process. The adapter keeps one output request pending, for up to one second while idle. The server checks for output every 40 ms during that wait, in addition to the native worker and bridge latency. Reattachment replays the retained bytes, so after truncation a full-screen program may need to redraw. + +Prepare a publishable `@webfront/pty` archive with `wf run pty-package` from the repository developer project. The example below uses the same adapter source directly. + +## Run the example + +The [standalone example](../examples/pty/) opens the system shell in the application's working directory. Run the following commands from the repository root in a POSIX shell with the WebFront developer environment available for the `wf` commands. + +```sh +cmake -S examples/pty -B build-pty-example -DWEBFRONT_AUTODETECT_NATIVE=OFF +cmake --build build-pty-example +(cd build-pty-example/page && wf restore && wf build) +./build-pty-example/WebFrontPtyExample build-pty-example/page/.webfront/developer/build +``` + +CMake stages the browser sources, pinned packages and adapter in `build-pty-example/page`. On Windows, pass the same build output directory to `WebFrontPtyExample.exe` in the chosen CMake configuration's output directory. diff --git a/docs/TEST_TIERS.md b/docs/TEST_TIERS.md index de69ee1e..9182ae3b 100644 --- a/docs/TEST_TIERS.md +++ b/docs/TEST_TIERS.md @@ -28,6 +28,11 @@ declaration order, which is what makes four processes started separately split t share a process: `test/unit/ScenarioIsolation.cpp` restores the process-wide state a scenario may change. Run directly, `tests` draws a random order and prints its seed, which `tests --rng-seed ` replays. +The `startup` label selects the cases `StartupTime-cold` and `-warm` (#611), which belong to the standard tier: +`ctest -L startup` runs them alone, and they print the measured times with `-V`. "Cold" means fresh `HOME` and `XDG_*` +directories (Linux: empty GStreamer registry and font cache) and, on Windows, fresh `LOCALAPPDATA` and `APPDATA`; on macOS the +variables have little effect, so the cold case there only guarantees a new profile directory. + ## Waiting for an asynchronous state A unit test waits for an observable state, never for a fixed pause. `requireEventually(condition)` ends the scenario when diff --git a/docs/WEBKITGTK.md b/docs/WEBKITGTK.md index cab3729a..c827f331 100644 --- a/docs/WEBKITGTK.md +++ b/docs/WEBKITGTK.md @@ -61,6 +61,34 @@ On WSLg, preserve its supplied display variables and runtime directory. Native Wayland and WSLg require manual verification on those desktops; automated coverage uses X11/Xvfb. No WSL-specific library environment changes are applied. +### Snap-hosted editor terminals + +A terminal inherited from a Snap-packaged editor can expose Snap library or GTK +module paths to a host application. This has been observed with VSCodium: the +system WebKit network process loaded Snap's `libpthread.so.0` and failed with a +`GLIBC_PRIVATE` symbol error. The particular variable responsible has not been +isolated; other Snap-hosted editors, including VS Code, may pass similar paths, +but have not been verified. WebFront warns when the common variables below contain +`/snap/` or `/var/lib/snapd/snap/` paths outside verified Snap confinement. This +heuristic does not prove a failure or cover every possible path and does not alter +the environment. The warning uses the WebFront logger and can be filtered by the +application. + +If this failure occurs, start the host application with a clean environment for +these variables, replacing the executable path as needed: + +```bash +env -u LD_LIBRARY_PATH -u LD_PRELOAD \ + -u GIO_MODULE_DIR -u GTK_PATH -u GTK_EXE_PREFIX \ + -u GTK_IM_MODULE_FILE -u GSETTINGS_SCHEMA_DIR -u LOCPATH \ + ./examples/WebFrontLifeDeveloper +``` + +This removes all values of those variables for the application and its children, +including legitimate custom configuration. Adjust the launcher if it needs any of +them. WebFront cannot safely remove them globally: the host application and other +threads may depend on them, and WebKit may launch child processes later. + Persistent data lives in `$XDG_DATA_HOME/webfront/-` and caches in `$XDG_CACHE_HOME/webfront/-`. Absolute XDG paths are honored; otherwise absolute `$HOME/.local/share` and `$HOME/.cache` are used. The stable hash @@ -97,6 +125,76 @@ unit tests cover the policy decision table, null error diagnostics, preserving the first failure when a timeout or callback reports a later error, and the sandbox launcher check described below. +## Startup and first display + +The window is mapped at once, but almost transparent, and becomes opaque when the page reports its first frame (two +animation frames after `DOMContentLoaded`). If no frame is reported, a one-second timer shows it anyway, even when the +server has sent nothing yet, so a window may still appear empty (in the colour of `background`, if any) when the load is +slow; GLib can also run the timer late when other events keep the main loop busy. Without a compositing manager the +opacity is ignored and the window appears immediately, as before. The navigation timeout and its diagnostics are +unchanged. `WindowOptions::background` (`"#rgb"`, `"#rrggbb"` or `"#rrggbbaa"`) is the colour of the view under the page, +so a dark interface does not flash white once the window is shown; only WebKitGTK applies it so far. +`WebKitGTKStartupTime-cold` and `-warm` (label `startup`, in the standard tier) start the lifecycle program's `startup-time` +scenario with the trace enabled and fail when the page needs more than 10 s (cold: fresh `HOME` and `XDG_*` directories, +hence an empty GStreamer registry and font cache) or 5 s (warm: the same directories after a first start) to answer the host. +The time runs from the start of the program, and each case also requires the window's `window shown` milestone (the close waits 1.5 s for it) and applies the limit to it. The limits only catch a regression of seconds on a loaded runner; they do not qualify the 500 ms and 1 s targets. +`WEBFRONT_STARTUP_TRACE=1` prints the view's milestones (session creation, view created, load started, first frame, +window shown) on standard error, in milliseconds since the process was executed; only the first frame notification of +the session is a milestone (a late one is marked as such), a reload is not. A close request (`requestClose()`) made +before the window is shown still ends the session. + +### Skipping GStreamer + +WebKitGTK initializes GStreamer in the page's process shortly after a page loads, even if it never uses media, and scans +every plugin when the registry is cold (the first launch of a user, and after each update of the system's plugins): up to +1.7 s during which the WebSocket handshake and the frames of the page are blocked. Disabling the media settings of the +view does not prevent it, and WebFront cannot know in advance whether a page will use media. An application whose pages +never use `