Skip to content
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

fix: Setup Desktop before opening notes on macOS #2369

Conversation

taratatach
Copy link
Member

@taratatach taratatach commented Dec 19, 2024

Desktop registers with the OS as being able to open Cozy Note
documents. Thus, when a user opens a local .cozy-note file Desktop
opens the associated note in the default browser.

On Linux and Windows we receive one of two events depending on the
state of the application when the file is opened:

  • second-instance when Desktop was already running
  • ready when Desktop was not running

In both cases the file path is found in the execution arguments.

On macOS however, the file path will be made available via a dedicated
open-file event in both situations.
When the application is not running though, we'll also receive a
ready event after the open-file event.

This is where we encountered a deadlock situation:

  • when receiving the ready event, we setup the application and start
    the synchronization unless asked not to (e.g. when opening a note
    while Desktop was not already running)
  • when receiving the open-file event, we request not to start the
    synchronization if the application was not already running but need
    to wait for the setup to complete to open the note

The setup process was only run if the synchronization should be
started or a note file path was passed as argument which only occurs
on Linux and Windows.
Therefore, the app was stuck, ever waiting for the setup process to
complete.

We now make sure the setup process is run as long as we have a valid
config.

Please make sure the following boxes are checked:

  • PR is not too big
  • it improves UX & DX in some way
  • it includes unit tests matching the implementation changes
  • it includes scenarios matching a new behaviour or has been manually tested
  • it includes relevant documentation

@taratatach taratatach self-assigned this Dec 19, 2024
@taratatach taratatach force-pushed the fix/do-not-hang-when-opening-notes-on-macos-while-desktop-is-off branch from 145492c to 1f72b23 Compare December 20, 2024 08:32
@taratatach taratatach force-pushed the fix/do-not-hang-when-opening-notes-on-macos-while-desktop-is-off branch from 1f72b23 to 3e109ab Compare January 7, 2025 15:04
@taratatach taratatach changed the title WIP: fix: Don't hang when opening note on macOS with Desktop off fix: Setup Desktop before opening notes on macOS Jan 7, 2025
@taratatach taratatach marked this pull request as ready for review January 7, 2025 15:06
  Desktop registers with the OS as being able to open Cozy Note
  documents. Thus, when a user opens a local `.cozy-note` file Desktop
  opens the associated note in the default browser.

  On Linux and Windows we receive one of two events depending on the
  state of the application when the file is opened:
  - `second-instance` when Desktop was already running
  - `ready` when Desktop was not running

  In both cases the file path is found in the execution arguments.

  On macOS however, the file path will be made available via a dedicated
  `open-file` event in both situations.
  When the application is not running though, we'll also receive a
  `ready` event **after** the `open-file` event.

  This is where we encountered a deadlock situation:
  - when receiving the `ready` event, we setup the application and start
    the synchronization unless asked not to (e.g. when opening a note
    while Desktop was not already running)
  - when receiving the `open-file` event, we request not to start the
    synchronization if the application was not already running but need
    to wait for the setup to complete to open the note

  The setup process was only run if the synchronization should be
  started or a note file path was passed as argument which only occurs
  on Linux and Windows.
  Therefore, the app was stuck, ever waiting for the setup process to
  complete.

  We now make sure the setup process is run as long as we have a valid
  config.
@taratatach taratatach force-pushed the fix/do-not-hang-when-opening-notes-on-macos-while-desktop-is-off branch from 3e109ab to 8fc560b Compare January 7, 2025 15:11
  This can help debugging issues when opening a note fails.
@taratatach taratatach merged commit c9b53ce into master Jan 7, 2025
12 of 16 checks passed
@taratatach taratatach deleted the fix/do-not-hang-when-opening-notes-on-macos-while-desktop-is-off branch January 7, 2025 16:22
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.

1 participant