From 32124d9256f30032ce182735e1a5bc7dd0b2d52e Mon Sep 17 00:00:00 2001 From: Austin Wang Date: Thu, 26 Mar 2026 16:01:53 -0700 Subject: [PATCH] Revert "Merge pull request #1915 from elvistranhere/fix/split-crash-intel-1870" (#2221) This reverts commit c5b306655da3809554a23c3c2abac4c06ae94d31, reversing changes made to 100612d96e12238e0864d4bd392b250b49aa951b. --- Sources/TabManager.swift | 4 +--- Sources/Workspace.swift | 35 ++++++----------------------------- 2 files changed, 7 insertions(+), 32 deletions(-) diff --git a/Sources/TabManager.swift b/Sources/TabManager.swift index e1be8e39..9776cf03 100644 --- a/Sources/TabManager.swift +++ b/Sources/TabManager.swift @@ -2289,9 +2289,7 @@ class TabManager: ObservableObject { workspace: Workspace? ) -> ghostty_surface_config_s? { if let panel = terminalPanelForWorkspaceConfigInheritanceSource(workspace: workspace), - let sourceSurface = panel.surface.liveSurfaceForGhosttyAccess( - reason: "tabManager.inheritedTerminalConfigForNewWorkspace" - ) { + let sourceSurface = panel.surface.surface { return cmuxInheritedSurfaceConfig( sourceSurface: sourceSurface, context: GHOSTTY_SURFACE_CONTEXT_TAB diff --git a/Sources/Workspace.swift b/Sources/Workspace.swift index ffa7bce9..77920681 100644 --- a/Sources/Workspace.swift +++ b/Sources/Workspace.swift @@ -45,14 +45,6 @@ func cmuxCurrentSurfaceFontSizePoints(_ surface: ghostty_surface_t) -> Float? { return nil } - // Best-effort check: reject unretained font pointers that no longer belong - // to a live malloc allocation. This does not prove the object is still a - // valid CTFont, but it filters out the common fully-freed/unmapped cases - // that previously crashed on Intel Macs (#1496, #1870). - guard cmuxPointerAppearsLive(quicklookFont) else { - return nil - } - let ctFont = Unmanaged.fromOpaque(quicklookFont).takeUnretainedValue() let points = Float(CTFontGetSize(ctFont)) guard points > 0 else { return nil } @@ -7225,9 +7217,7 @@ final class Workspace: Identifiable, ObservableObject { private func rememberTerminalConfigInheritanceSource(_ terminalPanel: TerminalPanel) { lastTerminalConfigInheritancePanelId = terminalPanel.id - if let sourceSurface = terminalPanel.surface.liveSurfaceForGhosttyAccess( - reason: "workspace.rememberConfigInheritanceSource" - ), + if let sourceSurface = terminalPanel.surface.surface, let runtimePoints = cmuxCurrentSurfaceFontSizePoints(sourceSurface) { let existing = terminalInheritanceFontPointsByPanelId[terminalPanel.id] if existing == nil || abs((existing ?? runtimePoints) - runtimePoints) > 0.05 { @@ -7319,25 +7309,13 @@ final class Workspace: Identifiable, ObservableObject { preferredPanelId: UUID? = nil, inPane preferredPaneId: PaneID? = nil ) -> ghostty_surface_config_s? { - var staleRootedFontFallback: Float? - - // Walk candidates in priority order and use the first panel with a live surface. - // This avoids returning nil when the top candidate exists but is not attached yet. + // Walk candidates in priority order and use the first panel that still exposes + // a runtime surface pointer. for terminalPanel in terminalPanelConfigInheritanceCandidates( preferredPanelId: preferredPanelId, inPane: preferredPaneId ) { - let rootedFontFallback = terminalInheritanceFontPointsByPanelId[terminalPanel.id] - guard let sourceSurface = terminalPanel.surface.liveSurfaceForGhosttyAccess( - reason: "workspace.inheritedTerminalConfig" - ) else { - if staleRootedFontFallback == nil, - let rootedFontFallback, - rootedFontFallback > 0 { - staleRootedFontFallback = rootedFontFallback - } - continue - } + guard let sourceSurface = terminalPanel.surface.surface else { continue } var config = cmuxInheritedSurfaceConfig( sourceSurface: sourceSurface, context: GHOSTTY_SURFACE_CONTEXT_SPLIT @@ -7357,13 +7335,12 @@ final class Workspace: Identifiable, ObservableObject { return config } - if let fallbackFontPoints = staleRootedFontFallback ?? lastTerminalConfigInheritanceFontPoints { + if let fallbackFontPoints = lastTerminalConfigInheritanceFontPoints { var config = ghostty_surface_config_new() config.font_size = fallbackFontPoints #if DEBUG - let fallbackSource = staleRootedFontFallback != nil ? "quarantinedRootedFont" : "lastKnownFont" dlog( - "zoom.inherit fallback=\(fallbackSource) context=split font=\(String(format: "%.2f", fallbackFontPoints))" + "zoom.inherit fallback=lastKnownFont context=split font=\(String(format: "%.2f", fallbackFontPoints))" ) #endif return config