FF desktop readiness: document-start scripts, host groups, Windows authored origin, fail-closed prebuilt - #36
Merged
Conversation
…thored origin, fail-closed prebuilt What FlutterFlow's desktop Test Mode and code editors need from flutter_cef, on macOS and Windows. - documentStartScripts + create-time JS channels. Both are carried to the renderer in the browser's CreateBrowser extra_info and installed in OnContextCreated, before the page's first script. They are installed again after a cross-site navigation. A throwing script is reported to the console and the next script still runs. macOS protocol v8, Windows v4 (op 0x41). - hostGroup: ephemeral sessions in one group share a single cef_host. A profile dir is minted only when a host is actually spawned. - onCreateFailed: CefWebView no longer retries a failed create. The failure is also reported for a createFailed or protocolMismatch processGone, so a consumer can fall back to another web view. - Windows serves authored documents at their real origin (op 0x3f, loadAuthored), as macOS does, so there is no 2 MB data: cap. The dispose op no longer requires the slot, which leaked a browser when a dispose raced its create. - macOS prebuilt: FLUTTER_CEF_REQUIRE_PREBUILT=1 makes fetch and embed fail closed. A prebuilt whose hash doesn't match the sources is removed instead of embedded. The host bundle keeps only the en locale paks, since CEF runs en-US anyway (311 MB -> 262 MB installed, about 12 MB less compressed). Verified on macOS with Flutter 3.47.1: new document_start_probe 13/13, plus the authored_origin, keyboard_shortcut, samesite and multiview probes, and 190 Dart tests. The Windows host and plugin are compiled by CI. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018RfksfS1ncw7gNNtrtNJVa
… digest CefWebView ran frame Undo/Redo/SelectAll/Copy/Cut/Paste in place of Ctrl+Z/Y/Shift+Z/A/C/X/V on Windows, so an editor that owns its undo stack and selection never saw them: in Monaco, undo did nothing and select-all selected only the hidden textarea. The chords now reach the page as raw keys, as the macOS ⌘ chords already do. Blink's key bindings run the edit command when the page leaves the key unhandled, and cef_host_win gains the macOS host's OnKeyEvent fallback for a key both left unhandled. A Ctrl chord (not Ctrl+Alt, which is AltGr) is never treated as text. fetch_cef.ps1 verified the tarball against a .sha1 fetched from the same CDN and only warned when it was missing. The digest is now pinned in the script, and a mismatch fails the build. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018RfksfS1ncw7gNNtrtNJVa
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.
Everything the FlutterFlow desktop Test Mode preview and code editors need from flutter_cef on macOS and Windows. It follows the #35 audit.
What changes
CefWebController(documentStartScripts: [...])runs each script in every main-frame document before the page's own scripts. Each script runs again after a cross-site navigation. If one throws, the error is reported to the console and the next script still runs.<head>script can post. This removes the OnLoadStart race.CreateBrowser'sextra_infoand are installed inOnContextCreated.hostGroup: ephemeral sessions in a group share onecef_host, which exits with the last of them. A profile dir is created only when a host actually spawns.onCreateFailed:CefWebViewstops retrying a failed create.onCreateFailed, and so docreateFailedandprotocolMismatchprocessGoneevents. The consumer can then fall back to another web view.kOpSetAuthoredHtml0x3f,loadAuthored), so the 2 MBdata:cap no longer applies.CefWebViewno longer turns them into edit commands;cef_host'sOnKeyEventruns the edit command only when the page leaves the key unhandled. Before this, Monaco's own undo stack and selection handling were bypassed.fetch_cef.ps1verifies the CEF download against a SHA-1 pinned in the script (fail closed), not one fetched from the same host as the tarball.FLUTTER_CEF_REQUIRE_PREBUILT=1makes fetch and embed fail closed.enlocale paks, since CEF runs en-US anyway. That takes it from 311 MB to 262 MB installed, about 12 MB less compressed. The list is configurable viaCEF_HOST_LOCALES.Verification
example/lib/document_start_probe.dart: 13/13 pass. It covers first document, cross-site document, channel-ready-before-first-script, throw isolation, host group sharing and lifetime, and a 3 MB authored document at a synthetic origin.authored_origin_probe,keyboard_shortcut_probe,samesite_probeandmultiview_probe.profile_probe's restart-persistence check fails the same way onorigin/mainwith an ad-hoc host, so it is not caused by this PR.onCreateFailed, the no-retry behaviour, and a check that the two copies ofdocument_start.hstay identical.windows-build), and a Dart test checks that each editing chord reaches the host as a raw key rather than an edit command. Runtime testing on Windows is pending.After merge
Publish the new host (
make publish-cef-host; the source hash changed). Then repin FlutterFlow to the merge SHA.🤖 Generated with Claude Code
https://claude.ai/code/session_018RfksfS1ncw7gNNtrtNJVa