Skip to content

Fix model opened from a URL being discarded on macOS - #852

Open
KuzuriAo wants to merge 1 commit into
Snapmaker:mainfrom
KuzuriAo:fix-url-open-blank-project
Open

KuzuriAo wants to merge 1 commit into
Snapmaker:mainfrom
KuzuriAo:fix-url-open-blank-project

Conversation

@KuzuriAo

Copy link
Copy Markdown

Fixes #851.

Opening a model from Snapmaker Space on macOS downloads and loads it correctly, and then the app discards it. The model is visible on the plate for a moment, the plate clears, and the title changes to "Untitled".

Cause

macOS does not pass the URL in argv. LaunchServices launches the app first and delivers the URL afterwards through GUI_App::MacOpenURL, so init_params->input_files is empty by the time post_init() inspects it and switch_to_3d is never set.

post_init() therefore continues into its ordinary startup path, which selects the home page and calls plater_->trigger_restore_project(1). That finds no backup to restore and starts a blank project, over the model MacOpenURL has just finished loading.

Windows is unaffected: the URL arrives in argv, switch_to_3d becomes true, and the whole block is skipped.

The change

MacOpenURL sets m_url_open_pending, and post_init() checks it at the point switch_to_3d cannot reach. That gives the macOS URL path the same treatment the argv path already gets.

MacOpenURL is macOS-only, so Windows and Linux are unchanged by construction. The info log line makes it possible to confirm the path from a user's log without reproducing anything.

Verification

Built and tested on macOS 26.6.2, Apple Silicon.

  • Model opened from a Space link stays on the plate and the app stays on Prepare. Five consecutive runs, all with the url open pending line present and no Reset Project snapshot after load project done.
  • Confirmed with both a small model and a large one (a 2 second download and a 12 second download), since the original report wrongly described this as a timing race.
  • Normal launch still takes the unguarded path: several launches from the app icon, all reaching trigger_restore_project as before.

Not yet exercised on my side, and worth a look in review: restoring an unsaved project after a crash, and double-clicking a .3mf in Finder. Neither goes through MacOpenURL, so neither should see the flag set, but I would rather say so than imply I tested them.

The two public models used are linked in #851 for anyone wanting to reproduce. Note that it only reproduces on a cold launch: if Snapmaker Orca is already running and has finished starting up, it works fine, which is why this has been hard to recur.

Note on crash recovery

trigger_restore_project is also what offers to restore an unsaved project after a crash. That prompt is skipped only when a URL open is in flight, which seems right: the user asked for a specific model. It is unaffected on every other launch path. Happy to gate it differently if you would prefer the prompt still appear.

Opening a model from Snapmaker Space downloads and loads it correctly, and
then post_init() throws it away. The model appears on the plate for a moment,
the plate clears and the title becomes "Untitled".

macOS does not pass the URL in argv. LaunchServices starts the app first and
delivers the URL afterwards through MacOpenURL, so init_params->input_files is
empty and switch_to_3d is never set. post_init() therefore takes its ordinary
startup path, sends the user to the home page and calls trigger_restore_project,
which starts a blank project over the model MacOpenURL is loading.

Windows is unaffected because the URL does arrive in argv, switch_to_3d is true,
and that whole block is skipped.

Set a flag in MacOpenURL and check it where switch_to_3d cannot reach, which
gives the URL path on macOS the same treatment it already gets elsewhere.

Fixes OrcaSlicer#851
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

macOS: model opened from Snapmaker Space is loaded, then discarded by a project reset during startup

1 participant