Attribute performance reports via JS self-profiling and denoise long-task prompts / 性能报告接入采样归因并为长任务提示降噪#6374
Merged
SivanCola merged 2 commits intoJul 12, 2026
Conversation
…ompts Production telemetry shows performance-pressure reports dominating crash triage (~18k in 30 days) while carrying no actionable stacks, and the cumulative long-task rule fires on routine streaming-render bursts. - Sample JS stacks with the Self-Profiling API: a rolling 10ms/60s profiler is stopped when a performance prompt fires, and samples that landed inside recorded long-task windows (plus the lag spike itself for event-loop reports) are aggregated into a leaf-frame self-time top list, reported as "long task top frames (sampled)". - Serve Document-Policy: js-profiling from the Wails asset server so Chromium WebViews (WebView2) expose the Profiler API; WebKit ignores both the header and the API and keeps the unattributed report shape. - Record longtask culprit attribution, surfacing only cross-context anomalies (self/window culprits carry no signal). - Raise the cumulative long-task prompt budget from 1.5s to 3s per 60s window; extract shouldPromptForLongTasks for direct coverage. - Mention sampled app function names in the report privacy note.
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.
Problem
Performance-pressure diagnostics dominate crash triage volume (~18k reports over 30 days across
performance.longtask/performance.lag/performance.heap, versus 400 for the highest-volume real crash group), yet none of them carry a stack —longtaskPerformanceObserver entries have no attribution beyond a culprit descriptor, so the reports are unactionable. Separately, the cumulative long-task rule (>=3 tasks && >=1.5s total per 60s) fires on routine streaming-render bursts (e.g. 16 tasks of 70–240ms), which is a large part of that volume.Changes
Attribution (frontend + Go asset server)
long task top frames (sampled)section to the report, e.g.42x post (wails://wails/assets/vendor-markdown.js:1:130216).Document-Policy: js-profilingfrom the Wails asset server (jsProfilingMiddleware, chained before the workspace-media middleware). Chromium WebViews (WebView2 — the dominant platform for these reports) honor it; WebKit ignores both the header and the API, so macOS/Linux keep today's report shape.longtaskculprit attribution on each sample, but only surface anomalies (cross-context culprits / named containers);self/windowcarries no signal and is omitted.Denoise
shouldPromptForLongTaskswith direct test coverage.Backward compatibility
CrashPayload(schemaVersion: 2)messagestringPerformanceSnapshotattribution,longTaskFrames)localStoragereasonix:perf-reportedDocument-Policyheader; WebKit/older WebViews ignore unknown policiesstartLongTaskProfilerno-ops / catches, prompt path falls back to the synchronous unattributed reportVerification
tsx src/__tests__/crash-reporting.test.ts— 60 passed, 0 failed (new coverage: threshold boundaries incl. the 16×~100ms streaming burst staying silent, attribution formatting, trace aggregation windowing/capping, report context formatting)pnpm test(full frontend suite) — passtsc --noEmit -p tsconfig.test.json— passcd desktop && go build ./... && go test .— pass (rebased onto latestmain-v2, which also touchedapp.goand the locale files)Follow-up (separate PR): the sampled data is expected to confirm full-document markdown re-parse per streaming frame as the dominant long-task source; block-level memoization of completed markdown blocks is the planned fix.