Skip to content

Sol crashes when macOS switches between light and dark mode several times in a row #349

Done

Description

@andples

Sol crashes when macOS switches between light and dark mode several times in a row

Version: 2.1.364, macOS 27 (Apple Silicon)

Steps to reproduce

  1. Open Sol.
  2. Toggle the system appearance quickly, for example:
    for i in $(seq 1 12); do
      osascript -e 'tell application "System Events" to tell appearance preferences to set dark mode to not dark mode'
      sleep 0.15
    done
  3. Sol crashes, usually within the first dozen toggles.

I hit this with a theme switcher that changes the appearance as you flip through themes, but toggling by hand quickly does it too.

Crash

EXC_BAD_ACCESS (SIGSEGV), KERN_INVALID_ADDRESS at 0x0. Two variants of the faulting thread:

Thread (com.apple.root.user-initiated-qos)
0  hermes   facebook::jsi::Value::~Value() + 40
1  sol      ...
2  sol      ...
3  libsystem_blocks.dylib  _call_dispose_helpers_excp + 48
4  libsystem_blocks.dylib  _Block_release + 236
5  libdispatch.dylib       _dispatch_client_callout + 16
Thread (com.facebook.react.JavaScript)
0  hermes   facebook::jsi::Value::~Value() + 40
1  sol      ...
   ...
8  libsystem_blocks.dylib  _call_dispose_helpers_excp + 48
9  libsystem_blocks.dylib  _Block_release + 236
10 CoreFoundation          __CFRunLoopDoBlocks + 412

Cause (I think)

onColorSchemeChange restarts the JS runtime on every appearance change, and the new runtime calls getApplications, which holds resolve/reject (jsi::Value) and jsi::Runtime & on a background queue. When the next restart lands before the scan finishes, those values are freed after their runtime is gone, or run on the new runtime through the global invoker. I have a fix ready and will open a PR referencing this issue.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions