Repository navigation
macOS: open .bup files that launch BenchUp - #67
Merged
Merged
Conversation
When macOS starts BenchUp to open a document, AppKit dispatches the open-documents event during finishLaunching, before eframe creates the app and before desktop_files::initialize() added application:openFiles: to winit's delegate. AppKit then fell back to its document controller and reported that BenchUp cannot open the BenchUp project format. Observe NSApplicationWillFinishLaunchingNotification from main() before the event loop starts. It fires after winit sets its delegate and before AppKit dispatches launch documents, so the handler is in place in time. Once installed, AppKit also delivers command-line documents through it, so launch arguments are only read directly when the handler is missing. The queue now accepts only .bup paths, makes them absolute, and opens a repeated request once. The macOS bridge uses the objc2 crates already in the dependency tree through eframe. Fixes BenchUp3D#58 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
Author
|
@dannycoulombe heads-up: the failing Test core check here isn't caused by this PR. It comes from
I left it out of this PR to keep the fix scoped to #58. |
Collaborator
|
@furilo Yes, more often than not, they're related to recent updates elsewhere. No worries! You can leave it to me. I'll fix it directly in the PR. |
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.
Fixes #58.
Problem
On macOS, opening a
.bupwhile BenchUp is not running (Finder double-click,open file.bup,open -b … file.bup) started the app and then showed "BenchUp cannot open files in the 'BenchUp project' format".AppKit dispatches the launch open-documents event during
finishLaunching, before eframe creates the app.desktop_files::initialize()only addedapplication:openFiles:to winit's delegate from inside the app constructor, so at launch there was no handler and AppKit fell back toNSDocumentController.Fix
main()calls the newdesktop_files::prepare_launch()beforeeframe::run_native. On macOS it observesNSApplicationWillFinishLaunchingNotification, which fires after winit sets its delegate and before AppKit dispatches launch documents. The observer addsapplication:openFiles:to the delegate at that point, and the files go into the existing queue that the app drains every frame.run_nativewould not work, because NSApplication installs its own handlers during launch and replaces it. eframe has no hook between building the event loop and running it.initialize()therefore reads launch arguments directly only when the handler could not be installed, so files are not queued twice. Other platforms are unchanged..buppaths, makes relative paths absolute, and opens a repeated request once (the file requested last stays open).objc2/objc2-app-kit/objc2-foundationcrates instead of hand-writtenobjc_msgSendtransmutes. They are the versions eframe, egui-winit and rfd already use, so no new crates enter the lockfile.Testing
Tested on macOS with a debug build placed in a copy of the app bundle, with an isolated
HOME. A launch counted as opened when the autosavedmodel.jsonreferenced the document:open -a BenchUp.app file.bupwith BenchUp closedopen -a BenchUp.app --args file.bup(current CLI workaround)cargo test -p benchup-app --lib desktop_files: passes. New unit tests cover queue de-duplication and order, plus path filtering and normalisation.🤖 Generated with Claude Code