wakatime / macos-wakatime

Mac system tray app for automatic time tracking and metrics generated from your Xcode, Figma, Postman, etc. usage.
https://wakatime.com/mac
BSD 3-Clause "New" or "Revised" License
127 stars 22 forks source link

Harden against potential background crashes #102

Closed starbugs closed 1 year ago

starbugs commented 1 year ago

Fixes #75

This adds two precautions to avoid future crashes:

  1. Process.launch() can throw ObjC exceptions and those are now bridged to Swift and handled. Process.launch() is deprecated on macOS 14 or newer. So I added a Process extension that automatically uses the right method and provides exception handling in all cases.
  2. The WakaTime state variables lastFile and lastTime are currently being read and written on a single worker thread and strictly don't require any thread safety guarantees for the time being. However, devs could break this in the future by accessing lastFile or lastTime on a separate thread concurrently. This has a potential to cause crashes, especially with concurrent writes. So I added an Atomic property wrapper that makes those two properties atomic.
Demircivi commented 1 year ago

Thank you for this :). I just realized my app crashed in the background(#75), and IDK when it crashed😂.

When will we get a release that contains this fix? @alanhamlett