-
Notifications
You must be signed in to change notification settings - Fork 93
perf: reduce WindowServer compositing cost and layout measurement overhead #23515
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
Changes from all commits
89df710
9775300
2bad7ae
dfdac2c
3a24b91
c622748
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -359,10 +359,12 @@ public final class MainWindowState: ObservableObject { | |
| base64Data: base64Data, | ||
| lazyAttachmentId: lazyAttachmentId, | ||
| fullResImage: nil, | ||
| isLoadingFullRes: lazyAttachmentId != nil | ||
| isLoadingFullRes: lazyAttachmentId != nil || base64Data != nil | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Unnecessary loading spinner shown in lightbox when image is already full-resolution The change to Prompt for agentsWas this helpful? React with 👍 or 👎 to provide feedback. |
||
| ) | ||
| if lazyAttachmentId != nil { | ||
| fetchFullResLightboxImage() | ||
| } else if let base64Data, !base64Data.isEmpty { | ||
| decodeBase64LightboxImage(base64Data) | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -378,8 +380,26 @@ public final class MainWindowState: ObservableObject { | |
| guard !Task.isCancelled else { return } | ||
| if let data, let fullRes = NSImage(data: data) { | ||
| self?.imageLightbox?.fullResImage = fullRes | ||
| // Update base64Data so toolbar actions (copy, save) use full-res | ||
| // We don't have a direct setter, but fullResImage is preferred by displayImage | ||
| } | ||
| self?.imageLightbox?.isLoadingFullRes = false | ||
| } | ||
| } | ||
|
|
||
| /// Decode base64 image data off the main thread using thread-safe ImageIO | ||
| /// APIs and set `fullResImage` once complete. | ||
| private func decodeBase64LightboxImage(_ base64Data: String) { | ||
| lightboxFetchTask = Task { @MainActor [weak self] in | ||
| let decoded: NSImage? = await Task.detached(priority: .userInitiated) { | ||
| guard let data = Data(base64Encoded: base64Data) else { return nil } | ||
| guard let source = CGImageSourceCreateWithData(data as CFData, nil), | ||
| let cgImage = CGImageSourceCreateImageAtIndex(source, 0, nil) else { | ||
| return nil | ||
| } | ||
| return NSImage(cgImage: cgImage, size: .zero) | ||
| }.value | ||
| guard !Task.isCancelled else { return } | ||
| if let decoded { | ||
| self?.imageLightbox?.fullResImage = decoded | ||
| } | ||
| self?.imageLightbox?.isLoadingFullRes = false | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.