diag(macos): os_signpost markers around transition + fixedSize boundaries (LUM-1116 Phase 1)#27552
Merged
Merged
Conversation
…ries (LUM-1116 Phase 1) Add `layoutHangSignpost(_:)` view modifier that emits `.event` os_signpost markers (category `layout-hangs`) on appear/disappear, and apply it at every `.transition(.move…)` site plus the two confirmed `.fixedSize()` component boundaries. Production Sentry main-thread hangs (MACOS-66 and related) land with a fingerprint of `SizeFittingLayoutComputer.Engine.explicitAlignment → _HStackLayout → Color → MoveTransition.MoveLayout → nested _VStackLayouts → StackLayout.prioritize → MutableCollection.sort`, but no user-defined view names — so we can't tell which `.transition(.move…)` call site is the culprit. These signposts ship in the spindump / Instruments track alongside future hang events, turning the ambiguous stack into an actionable view identifier. Pure diagnostics — no behavior change. `.event` signposts with StaticString names allocate nothing and are safe on the main thread.
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.
Summary
layoutHangSignpost(_:)SwiftUI view modifier inTelemetry/PerfSignposts.swiftthat emitsos_signpost(.event …)markers ononAppear/onDisappearagainst a newlayout-hangslog category..transition(.move…)site in the macOS app (13 sites) and at two.fixedSize()component boundaries (composer outer VStack, queued-messages drawer).os_signpostsyscall.StaticStringnames guarantee zero allocation on the main thread.Why
Sentry main-thread hangs in
MACOS-66and related (LUM-1116) fingerprintSizeFittingLayoutComputer.Engine.explicitAlignment → _HStackLayout × 2 → Color → MoveTransition.MoveLayout → _VStackLayout × 5 → StackLayout.prioritize → MutableCollection.sort. The stack contains zero user-defined view names, so we can't tell which.transition(.move…)call site is driving it.LUM-1111(MACOS-KE) separately confirms a sidebar transition can hang — direct evidence that this code path is implicated.With
.eventsignposts emitting a view name on appear/disappear, the next hang event will ship with a recent signpost breadcrumb naming the active view — the missing piece needed to cut a Phase 2 targeted fix.This PR does not fix any hang by itself.
Instrumented sites
.transition(.move…)sitesFeatures/Chat/ComposerSection.swiftcomposer.watchProgressFeatures/Chat/ChatView.swiftchat.searchBarFeatures/Chat/ChatView.swiftchat.queuedMessagesDrawerFeatures/Chat/ChatView.swiftchat.btwOverlayFeatures/Chat/ChatErrorToastView.swiftchat.errorToastFeatures/Chat/ChatErrorToastView.swiftchat.creditsExhaustedBannerFeatures/Chat/ChatErrorToastView.swiftchat.compactionCircuitOpenBannerFeatures/Chat/ChatErrorToastView.swiftchat.missingApiKeyBannerFeatures/Chat/RecoveryModeBanner.swiftchat.recoveryModeBannerFeatures/Chat/ComposerView.swiftcomposer.slashCommandPopupFeatures/Chat/ComposerView.swiftcomposer.emojiPickerPopupFeatures/Chat/MessageListHelperViews.swiftchat.scrollToLatestOverlayFeatures/MainWindow/PanelCoordinator.swiftpanel.messageInspectorFeatures/MainWindow/MainWindowZoomIndicator.swiftmainWindow.zoomIndicatorFeatures/MainWindow/MainWindowToastOverlay.swiftmainWindow.toastOverlayFeatures/MainWindow/Panels/MemoriesPanel.swiftpanel.memories.detailSheetFeatures/MainWindow/Panels/IdentityPanel.swiftpanel.identity.sidebar.fixedSize()component boundariesFeatures/Chat/ComposerView.swiftcomposer.outerVStack.fixedSizeFeatures/Chat/QueuedMessagesDrawer.swiftchat.queuedMessagesDrawer.fixedSizeNote: leaf
Text.fixedSize()calls are intentionally NOT instrumented — they're cheap, frequent, and not the layout-engine boundary that matters for theSizeFittingLayoutComputerstack. LazyVStack cells are also intentionally skipped to avoid O(visible) × frames noise.Implementation
Extended the existing
PerfSignpostsnamespace (Telemetry/PerfSignposts.swift) instead of adding a new helper — there was already anos_signpostwrapper used for profiling, so we reuse the same module:StaticStringis required (notString) so the call site can't allocate. The log is a dedicated category (layout-hangs) distinct from the Points-of-Interest log thatPerfSignpostsalready uses, so these can be filtered cleanly without drowning in Markdown-parse / scroll-intent / body-evaluation signposts.Test plan
swift build --target VellumAssistantLibcompiles cleanly in the worktree.layout-hangs. Trigger any instrumented view (send a message to queue it, open a panel, show a banner) and confirmappear/disappearevents land in the track with the expected name.MACOS-66(or a relatedSizeFittingLayoutComputer.Engine.explicitAlignmenthang) to fire. Pull the spindump from the attached event, find the last fewos_signpostentries on thelayout-hangscategory, and identify the view name that was appearing/disappearing when the hang started. Use that to cut a targeted Phase 2 fix.Reading the signposts in Instruments
In a Sentry hang spindump, search for
layout-hangsin the unified-log section for the equivalent breadcrumb.Constraints respected
.onAppear/.onDisappearcallbacks added via a non-intrusivesome Viewmodifier..eventmarkers only (no begin/end intervals, noOSSignpostIDtracking).LazyVStackcells (O(visible × frames) blast radius).StaticStringnames — no main-thread allocation risk.Linear / Sentry
SizeFittingLayoutComputer.Engine.explicitAlignmentmain-thread hangs.SidebarSectionView.body.getter:147).Deferred
Phase 2 will use the signpost breadcrumb from the next production hang to cut a targeted fix (reshape the transition/fixedSize combination on the culprit view). No Phase 2 work in this PR.