Skip to content

fix sccache wiring + Windows server race, macOS panmirror packaging, Global Options TypeError, and shiny test stability - #17994

Merged
aza-torshko merged 14 commits into
rel-blue-plumbagofrom
aza/fix-windows-sccache-wiring
Jun 16, 2026
Merged

aza-torshko merged 14 commits into
rel-blue-plumbagofrom
aza/fix-windows-sccache-wiring

Conversation

@aza-torshko

@aza-torshko aza-torshko commented Jun 15, 2026 •

Copy link
Copy Markdown
Contributor

Intent

Make Windows and macOS PR builds reliable and fix three real product/test issues that surfaced while investigating the slow Windows compile path.

This PR groups four fixes that were diagnosed together:

  1. sccache wiring on Windows and macOS. Builds were running a full cold C++ compile every PR because sccache wasn't reaching the compile chain — sccache --show-stats consistently reported Compile requests: 0. Two separate causes were in play: a CMake launcher wiring problem affecting both platforms, and a Windows-specific server bind race.
  2. macOS visual editor missing on cache-hit builds. Three visual-mode e2e tests (render quarto document, spellcheck in visual mode, rmd templates display) failed deterministically on macOS because panmirror.js returned 404 — the bundle was missing from the installed package whenever the macOS GWT cache hit (--build-gwt=0).
  3. Global Options dismiss TypeError. Dismissing Tools > Global Options while the Appearance pane's editor theme preview was still loading raised an uncaught "Cannot read properties of null (reading 'document')" TypeError, displayed as an Error dialog. Same class of bug as fix shiny app window becoming unclosable and orphaned #17920's recent fix, different code path.
  4. Shiny window-close test stability. All three tests in shiny-app-window-close.test.ts were test.fixme'd on Windows because the R-side interrupt was unreliable, and the macOS path had a race between shiny's initial-binding pass and the test's interrupt.

Approach

sccache wiring (cmake/modules/sccache.cmake):

  • Set CMAKE_<LANG>_COMPILER_LAUNCHER as CACHE STRING "..." FORCE (launcher-only, not also RULE_LAUNCH_COMPILE). On the Ninja generator the two stack additively rather than acting as fallbacks; setting both produces compile rules like sccache sccache c++ -E ... and breaks with Compiler not supported: unexpected argument '-E' found. The file's comment documents the constraint.
  • MSVC: handle /Zi → /Z7 so parallel cl.exe invocations don't fight over a shared PDB (which causes C1041 errors with sccache). Three layers: add_compile_options(/Z7), CACHE FORCE to strip /Zi, and CMP0141.

Windows sccache server race (.github/workflows/os-test-e2e-rstudio-desktop-os-windows-server-2025.yml):

  • New "Start sccache server" step pre-starts sccache.exe --start-server with SCCACHE_IDLE_TIMEOUT=0. On Windows each parallel cl.exe compile spawns its own sccache.exe which tries to bind 127.0.0.1:4226; without a pre-started server the first one wins and the rest exit with WSAEADDRINUSE (os error 10048). After this change, Windows sccache hit rate went 0 → 98.31%.
  • Removed the SCCACHE_LOG/SCCACHE_ERROR_LOG env vars, the upload-sccache-log step, the verify-build.ninja diagnostic step (whose PowerShell -SimpleMatch + backtick escapes prevented it from running anyway), and the upload-ninja-files step — diagnostic scaffolding from the root-cause investigation that's no longer needed.

macOS panmirror packaging (src/gwt/build.xml):

  • Single-line change: panmirror.build.dir = ${www.dir}/js/panmirror (was hardcoded to ./www/js/panmirror). cmake on macOS overrides www.dir to a build-tree absolute path; the prior relative path resolved to the source tree instead, so panmirror dropped out of the cached gwt build-tree directory. On Windows/Linux/local where www.dir defaults to ./www, the resolved path is unchanged. The cache key already hashes build.xml, so the stale cache invalidates automatically and the next run reseeds with panmirror inside.

Global Options TypeError (src/gwt/src/org/rstudio/studio/client/workbench/prefs/views/AceEditorPreview.java):

  • The deferred ExternalJavaScriptLoader.onLoaded callbacks were dereferencing getWindow().getDocument() on a detached iframe (Global Options dismissed before Ace finished loading). getDocument() in DynamicIFrame is getWindow().getDocument() over JSNI return this.document — on a detached frame getWindow() returns null and null.document raises the TypeError surfaced as an Error dialog.
  • Added the same isAttached() + null-window / null-document guards fix shiny app window becoming unclosable and orphaned #17920 applied to setLineHeight, extended to the outer/inner onLoaded callbacks and to setTheme / setFontSize / setFont for completeness.

Shiny test stability (e2e/rstudio/tests/shiny/shiny-app-window-close.test.ts, ApplicationAutomation.java, e2e/rstudio/utils/commands.ts):

  • New window.rstudio.shiny.stopForegroundApp() automation bridge that calls the existing stop_shiny_app JSON-RPC handler (which invokes shiny::stopApp() on the R side). Test 1 ("window closes when the app is stopped") now uses this bridge instead of clicking the interrupt button. Interrupt depends on R_interrupts_pending being polled inside runApp's event loop — unreliable on Windows where the OS uses CTRL_BREAK_EVENT rather than SIGINT. The RPC goes through shiny's normal shutdown on every platform, which lets the three Windows test.fixmes come off.
  • Replaced the waitForTimeout(500) in waitForShinyIdle with a stability-counted expect.poll (5 consecutive shiny-busy=false samples at 100ms intervals) — a measurable condition per e2e/rstudio/docs/ANTIPATTERN_CLEANUP.md.
  • Wrapped ensureConsoleIdle in the afterAll hook with try/finally so a still-busy R can't leak the temp app dir into the next worker.
  • Trimmed the ensureConsoleIdle nudge loop down to a single retry — repeated interruptR calls against a stuck R stack "Terminate R" confirmation dialogs in the IDE.

Automated Tests

This is a CI infrastructure / latent-bug PR with no new product feature, so verification is the next CI runs on this branch:

  • Windows: sccache --show-stats reports non-zero compile-requests (saw 98.31% hit rate after the fix).
  • macOS shards 1 and 2: e2e went from consistent failure (3 visual-mode timeouts on shard 1, shiny timeouts on shard 2) to consistent success.
  • Windows shard 2: the dismissAll-Global-Options test went from FAIL with stacked Terminate R dialogs to passing.
  • Shiny test 1 runs on Windows without the test.fixme skip.

QA Notes

The AceEditorPreview change is the only user-observable behavior change here; the rest are CI / build-system.

To exercise the AceEditorPreview fix manually: open Tools > Global Options, switch to the Appearance pane (which mounts the editor theme preview), and dismiss the dialog quickly via Cancel/Escape before the preview finishes loading. Previously this could surface an "Error" dialog reading "Cannot read properties of null (reading 'document')"; that dialog should no longer appear.

Documentation

NEWS.md entries added under ### Fixed:

  • The AceEditorPreview detached-frame TypeError (user-observable).
  • The macOS panmirror packaging fix (per reviewer request; affects cache-hit builds only).

The build-system changes (sccache wiring, Windows server pre-start, workflow scaffolding removal, shiny automation bridge, build.xml panmirror path) need no admin/user docs.

Checklist

  • If this PR adds a new feature, or fixes a bug in a previously released version, it includes an entry in NEWS.md
  • If this PR adds or changes UI, the updated UI meets accessibility standards — n/a, no UI changes
  • A reviewer is assigned to this PR (if unsure who to assign, check Area Owners list)
  • This PR passes all local unit tests

@github-actions

github-actions Bot commented Jun 15, 2026 •

Copy link
Copy Markdown

🍎 macOS Desktop E2E · ARM64

✅ All tests passed!

████████████████████ 100% pass rate

✅ Passed ❌ Failed ⚠️ Skipped 🔁 Flaky
388 0 11 0
📥 Download Playwright report

⬇️ playwright-report.zip — extract and open index.html

Includes screenshots, traces, and step-by-step details for every test. Expires in 15 days.


2 shards · macos-26 ARM64 · commit 57d2935b8689bc433c8918c0b165444d0250f652 · Run #61

@github-actions

github-actions Bot commented Jun 15, 2026 •

Copy link
Copy Markdown

🪟 Windows Desktop E2E · Server 2025 x64

✅ All tests passed!

████████████████████ 100% pass rate

✅ Passed ❌ Failed ⚠️ Skipped 🔁 Flaky
383 0 16 2
📥 Download Playwright report

⬇️ playwright-report.zip — extract and open index.html

Includes screenshots, traces, and step-by-step details for every test. Expires in 15 days.


2 shards · Windows Server 2025 x64 · commit 57d2935b8689bc433c8918c0b165444d0250f652 · Run #61

@aza-torshko

aza-torshko commented Jun 16, 2026 •

Copy link
Copy Markdown
Contributor Author

LGTM — re-reviewed on the latest commit and the previous diagnostics issue is fixed.

The sccache wiring/debug changes, the panmirror output path correction, and the shiny test stabilization all look good from a correctness standpoint.

Only remaining gate is CI completion (macOS/Windows build jobs are still pending).

— Review from GitHub Copilot (powered by GPT-5.3-Codex, model ID: gpt-5.3-codex).

@aza-torshko
aza-torshko marked this pull request as ready for review June 16, 2026 05:17
@aza-torshko
aza-torshko requested a review from kevinushey June 16, 2026 05:17
@aza-torshko
aza-torshko changed the base branch from main to rel-blue-plumbago June 16, 2026 14:34
@aza-torshko
aza-torshko requested a review from gtritchie June 16, 2026 14:35
@gtritchie gtritchie added this to the 2026.06 (Blue Plumbago) milestone Jun 16, 2026
@gtritchie

Copy link
Copy Markdown
Member

Code review findings

Actionable items from an automated multi-agent review.

Critical

  1. PR title and body describe the opposite approach from the code. Title says "wire sccache
    via RULE_LAUNCH_COMPILE + CACHE FORCE" and the body describes a "belt-and-suspenders" approach
    setting both RULE_LAUNCH_COMPILE and the launcher. cmake/modules/sccache.cmake:12-18 sets
    launcher-only and its comment explicitly says "Use only this mechanism -- NOT
    RULE_LAUNCH_COMPILE" (the two stack additively on Ninja -> sccache sccache c++ -E ...). Fix:
    rewrite the title and body to match the shipped launcher-only approach.

  2. .github/workflows/os-test-e2e-rstudio-desktop-os-windows-server-2025.yml:424-521 -- the
    SCCACHE_LOG/SCCACHE_ERROR_LOG env, "Upload sccache error log", "Verify sccache is wired into
    build.ninja", and "Upload ninja files" steps are debugging scaffolding for an unresolved
    investigation (comments read "The build is still reporting Compile requests: 0...") and exist
    in no sibling Windows workflow. The PowerShell at line 485 is itself broken -- backticks around
    `command =` are consumed as escapes and \$LAUNCHER prints as a bare \ (undefined
    variable), so the diagnostic was never actually run. Fix: remove this scaffolding before merge,
    or hold the change until the Compile requests: 0 root cause is resolved and the diagnostics
    deleted.

Important

  1. No issue association and no NEWS.md entry. AceEditorPreview.java fixes a user-facing
    uncaught-exception dialog (Global Options dismissed while Ace loads) and build.xml fixes macOS
    packages shipping without panmirror.js on cache-hit builds -- both affect released behavior.
    Fix: add ### Fixed entries / issue references, or state explicitly that these are
    regressions introduced on this unreleased branch (NEWS exemption).

  2. e2e/rstudio/tests/shiny/shiny-app-window-close.test.ts:41-49 -- waitForShinyIdle uses
    waitForTimeout(500), a tracked antipattern (e2e/rstudio/docs/ANTIPATTERN_CLEANUP.md:38,
    "wait for a measurable condition, not a fixed duration"). If the next Shiny render pass starts
    later than 500ms (slow CI), the re-check still races and reports false-idle, making the
    downstream interruptR flaky -- the symptom this change targets. Fix: replace with a
    stability-counted poll (expect.poll) or assert a real post-binding condition. The Windows
    test.fixme skips (:105, :122, :138) remain, so the underlying race is not actually
    fixed on the platform where it was observed; state this in the PR body.

  3. e2e/rstudio/tests/shiny/shiny-app-window-close.test.ts:95-100 -- ensureConsoleIdle (single
    interrupt + 10s wait) is now the sole guard before unlink(APP_DIR) in afterAll; if its final
    assertion throws, the unlink never runs and the temp app dir leaks to the next worker. Fix:
    decouple the cleanup from the idle assertion (e.g. try/finally).

Suggestions

  1. src/gwt/src/org/rstudio/studio/client/workbench/prefs/views/AceEditorPreview.java:184,199,233
    -- setTheme/setFontSize/setFont still dereference getDocument() guarded only by
    isFrameLoaded_, not isAttached(), unlike the hardened setLineHeight. Safe today (only
    reachable from synchronous user interaction), but a latent null-deref if any becomes reachable
    from an async path.

  2. src/gwt/build.xml:254-260 -- the comment singles out macOS ("e.g. macOS passes a build-tree
    absolute path"), but GWT_WWW_DIR is a generic cmake override. Generalize the parenthetical.

@gtritchie gtritchie left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

feedback attached, please review and address any findings you think are worth doing; I don't think this needs a NEWS entry (Claude always worries about that).

@aza-torshko aza-torshko changed the title wire sccache via RULE_LAUNCH_COMPILE + CACHE FORCE so it actually reaches the Windows compile rules fix sccache wiring + Windows server race, macOS panmirror packaging, Global Options TypeError, and shiny test stability Jun 16, 2026
@aza-torshko
aza-torshko requested a review from gtritchie June 16, 2026 18:54

@gtritchie gtritchie left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

@aza-torshko
aza-torshko merged commit cd797ba into rel-blue-plumbago Jun 16, 2026
15 checks passed
@aza-torshko
aza-torshko deleted the aza/fix-windows-sccache-wiring branch June 16, 2026 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants