Repository navigation
Revert PR 8848 before Ghostty lag fix #8893
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
99 changes: 0 additions & 99 deletions
99
...ages/iOS/CmuxMobileTerminal/Tests/CmuxMobileTerminalTests/GhosttyRuntimeActionTests.swift
This file was deleted.
Oops, something went wrong.
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
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift
🧩 Analysis chain
🏁 Script executed:
Repository: manaflow-ai/cmux
Length of output: 1866
🏁 Script executed:
Repository: manaflow-ai/cmux
Length of output: 245
🏁 Script executed:
Repository: manaflow-ai/cmux
Length of output: 13650
🏁 Script executed:
Repository: manaflow-ai/cmux
Length of output: 17635
🌐 Web query:
Ghostty ghostty_surface_free userdata iOS uiview platform ownership💡 Result:
In the Ghostty architecture, these components relate to how the terminal emulator interfaces with the host platform's UI and memory management: ghostty_surface_free This is a C API function provided by libghostty [1][2]. It is used to deallocate a terminal surface and its associated resources, such as Metal rendering structures and terminal grid state [3][4]. When called, it initiates the teardown of the renderer and associated platform-specific layers (like IOSurface or Metal layers on Apple platforms) [5]. userdata The userdata pointer is an arbitrary
void*provided in the ghostty_surface_config_s configuration struct during the initialization of a surface [1][3]. It allows the embedding application to associate its own context (e.g., a Controller, ViewModel, or View object) with the Ghostty surface [2]. This pointer can be retrieved at any time using the ghostty_surface_userdata C API function [1][2]. iOS UIView and Platform Ownership On iOS, Ghostty uses a platform-native approach where the embedding application provides a UIView into which Ghostty renders using Metal [3][4]. - Platform Data: The platform-specific configuration for iOS is defined in the ghostty_platform_ios_s struct, which contains a void* member named uiview to hold a reference to the host application's view [1][3]. - Ownership: Ghostty's core (libghostty) manages the terminal emulation, grid state, and Metal rendering pipeline [6][4]. However, the embedding application typically retains ownership of the native UI objects (like the UIView). Because Ghostty's renderer may perform asynchronous operations (e.g., presenting frames via Metal or Core Animation), issues such as use-after-free can occur if the host application frees its UI resources before Ghostty has finished its internal cleanup, necessitating careful synchronization during surface teardown [5]. The "lazy/pull" architecture often employed by Ghostty-based apps means the Zig core owns the terminal state, while the Swift/native wrapper queries it as needed [7].Citations:
🌐 Web query:
github ghostty-src ghostty_platform_ios.c ghostty_surface_free uiview💡 Result:
In the Ghostty terminal emulator codebase, ghostty_surface_free is a C API function used to deallocate a surface and its associated resources [1][2][3]. When operating on iOS, the surface uses platform-specific configuration defined by ghostty_platform_ios_s, which contains a void* pointer to a UIView [4][2][3]. Technical details regarding this implementation include: 1. Function Purpose: ghostty_surface_free serves as the primary cleanup mechanism for a terminal surface [1][2]. Internally, it triggers the application to close the surface, subsequently calling deinitialization routines [5][6]. 2. iOS Platform Data: The ghostty_platform_ios_s structure is defined in include/ghostty.h as a wrapper for a UIView pointer, allowing the terminal to render its output into that native iOS view, typically utilizing Metal for GPU acceleration [2][3]. 3. Implementation Context: The underlying logic is handled in Zig [5][6]. When ghostty_surface_free is called, it typically involves tearing down the renderer (such as Metal-based swap chains), stopping terminal threads, and releasing GPU-related resources like IOSurfaces and textures [7]. 4. Potential Issues: Developers should be aware of lifecycle management complexities, such as potential use-after-free scenarios if Metal completion handlers or Core Animation transactions attempt to reference resources (like an IOSurface) after they have been freed during the surface teardown process [7]. The C API and related structures are found within the include/ghostty.h header, and the platform-specific logic is managed in files such as src/apprt/embedded.zig [4][5][3].
Citations:
🌐 Web query:
ghostty src embedded.zig uiview ghostty_platform_ios_s💡 Result:
In the Ghostty terminal emulator codebase, ghostty_platform_ios_s is a C structure used within the embedded runtime API to provide platform-specific configuration for iOS [1][2]. It is defined in the public header file include/ghostty.h as follows: typedef struct { void* uiview; } ghostty_platform_ios_s; This structure contains a single member, uiview, which is a pointer to the UIView (cast to void*) where the terminal is intended to render [3][2]. The file src/apprt/embedded.zig acts as the Zig-side implementation of this embedded runtime [4][5]. Within this file, the Platform union (and its associated C compatibility union) handles the initialization and abstraction of these platform-specific views [6][7]. The init function in embedded.zig ensures that when the library is initialized, the uiview provided via the C ABI is properly cast and stored for use by Ghostty's rendering engine, which uses Metal to render to the specified view [6][3]. In practical usage, such as in the Swift-based surface view implementation, the host application passes a reference to its UIView—via an opaque pointer—to the libghostty configuration [8]. This allows Ghostty to function as an embedded component within a larger iOS application, rather than managing the entire application lifecycle itself [4][5].
Citations:
Keep the unretained platform view alive through teardown.
disposeSurface()detachescurrentBridgebefore this asynchronous free, so retaining the bridge no longer keepsGhosttySurfaceViewalive. SincemakeSurface()storesselfas an unretainedghostty_platform_ios_s.uiview, the pinned Ghostty teardown/cleanup path could still reference a released view. Retain the view on teardown until free completion, or replace the unretained platform userdata with a retained/pinned ownership object.🤖 Prompt for AI Agents