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
142 stars 23 forks source link

Crashing on v2.0.1 #115

Closed Demircivi closed 1 year ago

Demircivi commented 1 year ago

Log from the Console.app: If I get it correct, this method causes the crash.

I'm concerned about this force cast:

let activeWindow = element.getValue(for: kAXFocusedWindowAttribute) as! AXUIElement
-------------------------------------
Translated Report (Full Report Below)
-------------------------------------

Process:               WakaTime [88068]
Path:                  /Applications/WakaTime.app/Contents/MacOS/WakaTime
Identifier:            macos-wakatime.WakaTime
Version:               2.0.1 (2.0.1)
Code Type:             ARM-64 (Native)
Parent Process:        launchd [1]
User ID:               501

Date/Time:             2023-06-19 08:58:26.4714 +0300
OS Version:            macOS 13.4 (22F66)
Report Version:        12
Anonymous UUID:        FAB9A1F3-F1A3-6F8A-B2F4-7442A5B90BC1

Sleep/Wake UUID:       8D6C0010-7ED4-42A0-8FA5-EDCA6C804D64

Time Awake Since Boot: 270000 seconds
Time Since Wake:       38 seconds

System Integrity Protection: enabled

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BREAKPOINT (SIGTRAP)
Exception Codes:       0x0000000000000001, 0x0000000100d8d5c0

Termination Reason:    Namespace SIGNAL, Code 5 Trace/BPT trap: 5
Terminating Process:   exc handler [88068]

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   WakaTime                               0x100d8d5c0 Watcher.watch(app:) + 1460
1   WakaTime                               0x100d8cbe8 Watcher.handleAppChanged(_:) + 552
2   WakaTime                               0x100d8c828 Watcher.appChanged(_:) + 284
3   WakaTime                               0x100d8c8d8 @objc Watcher.appChanged(_:) + 128
4   CoreFoundation                         0x1a7e9b180 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 148
5   CoreFoundation                         0x1a7f36eec ___CFXRegistrationPost_block_invoke + 88
6   CoreFoundation                         0x1a7f36e34 _CFXRegistrationPost + 440
7   CoreFoundation                         0x1a7e6c4cc _CFXNotificationPost + 704
8   Foundation                             0x1a8dca8f4 -[NSNotificationCenter postNotificationName:object:userInfo:] + 88
9   AppKit                                 0x1ab2665e8 applicationStatusSubsystemCallback + 676
10  LaunchServices                         0x1a8327e30 ___LSScheduleNotificationFunction_block_invoke_2 + 52
11  CoreFoundation                         0x1a7ea61d4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 28
12  CoreFoundation                         0x1a7ea60e8 __CFRunLoopDoBlocks + 364
13  CoreFoundation                         0x1a7ea558c __CFRunLoopRun + 2432
14  CoreFoundation                         0x1a7ea44b8 CFRunLoopRunSpecific + 612
15  HIToolbox                              0x1b16eec40 RunCurrentEventLoopInMode + 292
16  HIToolbox                              0x1b16eea7c ReceiveNextEventCommon + 648
17  HIToolbox                              0x1b16ee7d4 _BlockUntilNextEventMatchingListInModeWithFilter + 76
18  AppKit                                 0x1ab0c5d44 _DPSNextEvent + 636
19  AppKit                                 0x1ab0c4ee0 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 716
20  AppKit                                 0x1ab0b9344 -[NSApplication run] + 464
21  WakaTime                               0x100d7d6c8 main + 120
22  dyld                                   0x1a7a6ff28 start + 2236

Thread 1:
0   libsystem_pthread.dylib                0x1a7dc2d8c start_wqthread + 0

Thread 2:
0   libsystem_pthread.dylib                0x1a7dc2d8c start_wqthread + 0

Thread 3:
0   libsystem_pthread.dylib                0x1a7dc2d8c start_wqthread + 0

Thread 4:: com.apple.NSEventThread
0   libsystem_kernel.dylib                 0x1a7d87f14 mach_msg2_trap + 8
1   libsystem_kernel.dylib                 0x1a7d9a240 mach_msg2_internal + 80
2   libsystem_kernel.dylib                 0x1a7d90b78 mach_msg_overwrite + 604
3   libsystem_kernel.dylib                 0x1a7d88290 mach_msg + 24
4   CoreFoundation                         0x1a7ea67e4 __CFRunLoopServiceMachPort + 160
5   CoreFoundation                         0x1a7ea50c4 __CFRunLoopRun + 1208
6   CoreFoundation                         0x1a7ea44b8 CFRunLoopRunSpecific + 612
7   AppKit                                 0x1ab1f0334 _NSEventThread + 172
8   libsystem_pthread.dylib                0x1a7dc7fa8 _pthread_start + 148
9   libsystem_pthread.dylib                0x1a7dc2da0 thread_start + 8

Thread 5:
0   libsystem_pthread.dylib                0x1a7dc2d8c start_wqthread + 0

Thread 6:
0   libsystem_pthread.dylib                0x1a7dc2d8c start_wqthread + 0

Thread 7:
0   libsystem_pthread.dylib                0x1a7dc2d8c start_wqthread + 0

Thread 8:
0   libsystem_pthread.dylib                0x1a7dc2d8c start_wqthread + 0

Thread 9:
0   libsystem_pthread.dylib                0x1a7dc2d8c start_wqthread + 0

Thread 0 crashed with ARM Thread State (64-bit):
    x0: 0x0000000000000000   x1: 0x0000000000000000   x2: 0x0000000000000000   x3: 0x0000600003b84f40
    x4: 0x000d1f6100000a03   x5: 0x0000070700000001   x6: 0x0000000000001048   x7: 0x00000000000005dc
    x8: 0x0000000000000100   x9: 0x00000000000000ff  x10: 0x0000000000000f00  x11: 0x00000000000007fb
   x12: 0x00000000da006814  x13: 0x00000000000007fd  x14: 0x00000000da20703d  x15: 0x00000000da006814
   x16: 0x00000001b6eb9b7c  x17: 0x000000005a200000  x18: 0x0000000000000000  x19: 0x0000600000096400
   x20: 0x0000000000000000  x21: 0x00000000ffff9d84  x22: 0x0000000203d78010  x23: 0x000000016f0855e0
   x24: 0x0000000203c95c58  x25: 0x000000016f0855c0  x26: 0x0000600000d8ce60  x27: 0x00006000020e6f10
   x28: 0x000000016f0855f0   fp: 0x000000016f0856e0   lr: 0x0000000100d8d5c0
    sp: 0x000000016f0855c0   pc: 0x0000000100d8d5c0 cpsr: 0x80001000
   far: 0x00000001095e0000  esr: 0xf2000001 (Breakpoint) brk 1

Binary Images:
       0x100d78000 -        0x100d97fff macos-wakatime.WakaTime (2.0.1) <491019e8-b56d-3813-8bb1-def204d7d343> /Applications/WakaTime.app/Contents/MacOS/WakaTime
       0x100ef4000 -        0x100f37fff org.sparkle-project.Sparkle (2.4.1) <85cd37f1-a154-35f6-8ee1-b0133b257fe1> /Applications/WakaTime.app/Contents/Frameworks/Sparkle.framework/Versions/B/Sparkle
       0x100ec8000 -        0x100ed3fff libobjc-trampolines.dylib (*) <570c31f7-94c6-3b86-ae44-1694db0a4bcd> /usr/lib/libobjc-trampolines.dylib
       0x1a7e27000 -        0x1a8300fff com.apple.CoreFoundation (6.9) <203e4401-8c2e-3157-a24b-92f52551d43e> /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
       0x1a8dc1000 -        0x1a9786fff com.apple.Foundation (6.9) <d5337cc6-a075-3ca0-b5bf-b49da8878337> /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation
       0x1ab08d000 -        0x1abf9bfff com.apple.AppKit (6.9) <041c7d21-21cc-3eea-ae53-d39f5ca6a24e> /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit
       0x1a8301000 -        0x1a857dfff com.apple.LaunchServices (1141.1) <556590f5-8fed-36a6-830b-ea49bd95b1fe> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/LaunchServices
       0x1b16be000 -        0x1b19f1fff com.apple.HIToolbox (2.1.1) <d800278b-4e6c-3032-b56f-027a938a51d6> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/HIToolbox
       0x1a7a6a000 -        0x1a7af8553 dyld (*) <bd993f39-c902-37d6-8bd8-6d827c7f121e> /usr/lib/dyld
       0x1a7dc1000 -        0x1a7dcdfff libsystem_pthread.dylib (*) <46d35233-a051-3f4f-bba4-ba56dddc4d1a> /usr/lib/system/libsystem_pthread.dylib
       0x1a7d87000 -        0x1a7dc0fe7 libsystem_kernel.dylib (*) <42f503e2-9273-360a-a086-c1b19bbd3962> /usr/lib/system/libsystem_kernel.dylib

External Modification Summary:
  Calls made by other processes targeting this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by all processes on this machine:
    task_for_pid: 67
    thread_create: 4
    thread_set_state: 10156

VM Region Summary:
ReadOnly portion of Libraries: Total=1.2G resident=0K(0%) swapped_out_or_unallocated=1.2G(100%)
Writable regions: Total=1.5G written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=1.5G(100%)

                                VIRTUAL   REGION 
REGION TYPE                        SIZE    COUNT (non-coalesced) 
===========                     =======  ======= 
Accelerate framework               128K        1 
Activity Tracing                   256K        1 
CG image                           112K        6 
ColorSync                          496K       25 
CoreAnimation                      688K       28 
CoreGraphics                        48K        3 
CoreServices                       256K        1 
CoreUI image data                 1648K       13 
Foundation                          16K        1 
Kernel Alloc Once                   32K        1 
MALLOC                           277.5M       58 
MALLOC guard page                  288K       14 
MALLOC_MEDIUM (reserved)         840.0M        7         reserved VM address space (unallocated)
MALLOC_NANO (reserved)           384.0M        1         reserved VM address space (unallocated)
SQLite page cache                  128K        1 
STACK GUARD                       56.2M       10 
Stack                             12.8M       10 
VM_ALLOCATE                        112K        7 
__AUTH                             855K      209 
__AUTH_CONST                      17.6M      392 
__CTF                               824        1 
__DATA                            6761K      381 
__DATA_CONST                      17.8M      396 
__DATA_DIRTY                       987K      136 
__FONT_DATA                        2352        1 
__LINKEDIT                       802.1M        4 
__OBJC_RO                         66.3M        1 
__OBJC_RW                         2011K        1 
__TEXT                           376.9M      415 
dyld private memory                272K        2 
libnetwork                         128K        8 
mapped file                       80.0M       28 
shared memory                      864K       13 
===========                     =======  ======= 
TOTAL                              2.9G     2176 
TOTAL, minus reserved VM space     1.7G     2176 

-----------
Full Report
-----------

{"app_name":"WakaTime","timestamp":"2023-06-19 08:58:28.00 +0300","app_version":"2.0.1","slice_uuid":"491019e8-b56d-3813-8bb1-def204d7d343","build_version":"2.0.1","platform":1,"bundleID":"macos-wakatime.WakaTime","share_with_app_devs":1,"is_first_party":0,"bug_type":"309","os_version":"macOS 13.4 (22F66)","roots_installed":0,"name":"WakaTime","incident_id":"4960D212-6950-4B61-9980-484FA568822D"}
{
  "uptime" : 270000,
  "procRole" : "Default",
  "version" : 2,
  "userID" : 501,
  "deployVersion" : 210,
  "modelCode" : "MacBookPro18,2",
  "coalitionID" : 47905,
  "osVersion" : {
    "train" : "macOS 13.4",
    "build" : "22F66",
    "releaseType" : "User"
  },
  "captureTime" : "2023-06-19 08:58:26.4714 +0300",
  "incident" : "4960D212-6950-4B61-9980-484FA568822D",
  "pid" : 88068,
  "translated" : false,
  "cpuType" : "ARM-64",
  "roots_installed" : 0,
  "bug_type" : "309",
  "procLaunch" : "2023-06-19 08:58:24.8585 +0300",
  "procStartAbsTime" : 6678466870264,
  "procExitAbsTime" : 6678505456626,
  "procName" : "WakaTime",
  "procPath" : "\/Applications\/WakaTime.app\/Contents\/MacOS\/WakaTime",
  "bundleInfo" : {"CFBundleShortVersionString":"2.0.1","CFBundleVersion":"2.0.1","CFBundleIdentifier":"macos-wakatime.WakaTime"},
  "storeInfo" : {"deviceIdentifierForVendor":"AF2A67F1-F4DC-5792-B1BC-0B7769AD3D7C","thirdParty":true},
  "parentProc" : "launchd",
  "parentPid" : 1,
  "coalitionName" : "macos-wakatime.WakaTime",
  "crashReporterKey" : "FAB9A1F3-F1A3-6F8A-B2F4-7442A5B90BC1",
  "codeSigningID" : "macos-wakatime.WakaTime",
  "codeSigningTeamID" : "538RQNWSWT",
  "codeSigningFlags" : 570503953,
  "codeSigningValidationCategory" : 6,
  "codeSigningTrustLevel" : 0,
  "wakeTime" : 38,
  "sleepWakeUUID" : "8D6C0010-7ED4-42A0-8FA5-EDCA6C804D64",
  "sip" : "enabled",
  "exception" : {"codes":"0x0000000000000001, 0x0000000100d8d5c0","rawCodes":[1,4309177792],"type":"EXC_BREAKPOINT","signal":"SIGTRAP"},
  "termination" : {"flags":0,"code":5,"namespace":"SIGNAL","indicator":"Trace\/BPT trap: 5","byProc":"exc handler","byPid":88068},
  "os_fault" : {"process":"WakaTime"},
  "extMods" : {"caller":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"system":{"thread_create":4,"thread_set_state":10156,"task_for_pid":67},"targeted":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"warnings":0},
  "faultingThread" : 0,
  "threads" : [{"triggered":true,"id":7696157,"threadState":{"x":[{"value":0},{"value":0},{"value":0},{"value":105553178677056},{"value":3693676169529859},{"value":7726646165505},{"value":4168},{"value":1500},{"value":256},{"value":255},{"value":3840},{"value":2043},{"value":3657459732},{"value":2045},{"value":3659558973},{"value":3657459732},{"value":7363861372,"symbolLocation":0,"symbol":"swift_unknownObjectRelease"},{"value":1512046592},{"value":0},{"value":105553116881920},{"value":0},{"value":4294942084},{"value":8654389264,"symbolLocation":0,"symbol":"type metadata for URL"},{"value":6157784544},{"value":8653462616},{"value":6157784512},{"value":105553130475104},{"value":105553150766864},{"value":6157784560}],"flavor":"ARM_THREAD_STATE64","lr":{"value":4309177792},"cpsr":{"value":2147487744},"fp":{"value":6157784800},"sp":{"value":6157784512},"esr":{"value":4060086273,"description":"(Breakpoint) brk 1"},"pc":{"value":4309177792,"matchesCrashFrame":1},"far":{"value":4452122624}},"queue":"com.apple.main-thread","frames":[{"imageOffset":87488,"symbol":"Watcher.watch(app:)","symbolLocation":1460,"imageIndex":0},{"imageOffset":84968,"symbol":"Watcher.handleAppChanged(_:)","symbolLocation":552,"imageIndex":0},{"imageOffset":84008,"symbol":"Watcher.appChanged(_:)","symbolLocation":284,"imageIndex":0},{"imageOffset":84184,"symbol":"@objc Watcher.appChanged(_:)","symbolLocation":128,"imageIndex":0},{"imageOffset":475520,"symbol":"__CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__","symbolLocation":148,"imageIndex":3},{"imageOffset":1113836,"symbol":"___CFXRegistrationPost_block_invoke","symbolLocation":88,"imageIndex":3},{"imageOffset":1113652,"symbol":"_CFXRegistrationPost","symbolLocation":440,"imageIndex":3},{"imageOffset":283852,"symbol":"_CFXNotificationPost","symbolLocation":704,"imageIndex":3},{"imageOffset":39156,"symbol":"-[NSNotificationCenter postNotificationName:object:userInfo:]","symbolLocation":88,"imageIndex":4},{"imageOffset":1938920,"symbol":"applicationStatusSubsystemCallback","symbolLocation":676,"imageIndex":5},{"imageOffset":159280,"symbol":"___LSScheduleNotificationFunction_block_invoke_2","symbolLocation":52,"imageIndex":6},{"imageOffset":520660,"symbol":"__CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__","symbolLocation":28,"imageIndex":3},{"imageOffset":520424,"symbol":"__CFRunLoopDoBlocks","symbolLocation":364,"imageIndex":3},{"imageOffset":517516,"symbol":"__CFRunLoopRun","symbolLocation":2432,"imageIndex":3},{"imageOffset":513208,"symbol":"CFRunLoopRunSpecific","symbolLocation":612,"imageIndex":3},{"imageOffset":199744,"symbol":"RunCurrentEventLoopInMode","symbolLocation":292,"imageIndex":7},{"imageOffset":199292,"symbol":"ReceiveNextEventCommon","symbolLocation":648,"imageIndex":7},{"imageOffset":198612,"symbol":"_BlockUntilNextEventMatchingListInModeWithFilter","symbolLocation":76,"imageIndex":7},{"imageOffset":232772,"symbol":"_DPSNextEvent","symbolLocation":636,"imageIndex":5},{"imageOffset":229088,"symbol":"-[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:]","symbolLocation":716,"imageIndex":5},{"imageOffset":181060,"symbol":"-[NSApplication run]","symbolLocation":464,"imageIndex":5},{"imageOffset":22216,"symbol":"main","symbolLocation":120,"imageIndex":0},{"imageOffset":24360,"symbol":"start","symbolLocation":2236,"imageIndex":8}]},{"id":7696227,"frames":[{"imageOffset":7564,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":9}]},{"id":7696228,"frames":[{"imageOffset":7564,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":9}]},{"id":7696231,"frames":[{"imageOffset":7564,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":9}]},{"id":7696264,"name":"com.apple.NSEventThread","frames":[{"imageOffset":3860,"symbol":"mach_msg2_trap","symbolLocation":8,"imageIndex":10},{"imageOffset":78400,"symbol":"mach_msg2_internal","symbolLocation":80,"imageIndex":10},{"imageOffset":39800,"symbol":"mach_msg_overwrite","symbolLocation":604,"imageIndex":10},{"imageOffset":4752,"symbol":"mach_msg","symbolLocation":24,"imageIndex":10},{"imageOffset":522212,"symbol":"__CFRunLoopServiceMachPort","symbolLocation":160,"imageIndex":3},{"imageOffset":516292,"symbol":"__CFRunLoopRun","symbolLocation":1208,"imageIndex":3},{"imageOffset":513208,"symbol":"CFRunLoopRunSpecific","symbolLocation":612,"imageIndex":3},{"imageOffset":1454900,"symbol":"_NSEventThread","symbolLocation":172,"imageIndex":5},{"imageOffset":28584,"symbol":"_pthread_start","symbolLocation":148,"imageIndex":9},{"imageOffset":7584,"symbol":"thread_start","symbolLocation":8,"imageIndex":9}]},{"id":7696265,"frames":[{"imageOffset":7564,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":9}]},{"id":7696266,"frames":[{"imageOffset":7564,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":9}]},{"id":7696267,"frames":[{"imageOffset":7564,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":9}]},{"id":7696268,"frames":[{"imageOffset":7564,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":9}]},{"id":7696269,"frames":[{"imageOffset":7564,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":9}]}],
  "usedImages" : [
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4309090304,
    "CFBundleShortVersionString" : "2.0.1",
    "CFBundleIdentifier" : "macos-wakatime.WakaTime",
    "size" : 131072,
    "uuid" : "491019e8-b56d-3813-8bb1-def204d7d343",
    "path" : "\/Applications\/WakaTime.app\/Contents\/MacOS\/WakaTime",
    "name" : "WakaTime",
    "CFBundleVersion" : "2.0.1"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4310646784,
    "CFBundleShortVersionString" : "2.4.1",
    "CFBundleIdentifier" : "org.sparkle-project.Sparkle",
    "size" : 278528,
    "uuid" : "85cd37f1-a154-35f6-8ee1-b0133b257fe1",
    "path" : "\/Applications\/WakaTime.app\/Contents\/Frameworks\/Sparkle.framework\/Versions\/B\/Sparkle",
    "name" : "Sparkle",
    "CFBundleVersion" : "2027"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 4310466560,
    "size" : 49152,
    "uuid" : "570c31f7-94c6-3b86-ae44-1694db0a4bcd",
    "path" : "\/usr\/lib\/libobjc-trampolines.dylib",
    "name" : "libobjc-trampolines.dylib"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 7111602176,
    "CFBundleShortVersionString" : "6.9",
    "CFBundleIdentifier" : "com.apple.CoreFoundation",
    "size" : 5087232,
    "uuid" : "203e4401-8c2e-3157-a24b-92f52551d43e",
    "path" : "\/System\/Library\/Frameworks\/CoreFoundation.framework\/Versions\/A\/CoreFoundation",
    "name" : "CoreFoundation",
    "CFBundleVersion" : "1977"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 7127961600,
    "CFBundleShortVersionString" : "6.9",
    "CFBundleIdentifier" : "com.apple.Foundation",
    "size" : 10248192,
    "uuid" : "d5337cc6-a075-3ca0-b5bf-b49da8878337",
    "path" : "\/System\/Library\/Frameworks\/Foundation.framework\/Versions\/C\/Foundation",
    "name" : "Foundation",
    "CFBundleVersion" : "1977"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 7164448768,
    "CFBundleShortVersionString" : "6.9",
    "CFBundleIdentifier" : "com.apple.AppKit",
    "size" : 15790080,
    "uuid" : "041c7d21-21cc-3eea-ae53-d39f5ca6a24e",
    "path" : "\/System\/Library\/Frameworks\/AppKit.framework\/Versions\/C\/AppKit",
    "name" : "AppKit",
    "CFBundleVersion" : "2299.60.124"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 7116689408,
    "CFBundleShortVersionString" : "1141.1",
    "CFBundleIdentifier" : "com.apple.LaunchServices",
    "size" : 2609152,
    "uuid" : "556590f5-8fed-36a6-830b-ea49bd95b1fe",
    "path" : "\/System\/Library\/Frameworks\/CoreServices.framework\/Versions\/A\/Frameworks\/LaunchServices.framework\/Versions\/A\/LaunchServices",
    "name" : "LaunchServices",
    "CFBundleVersion" : "1141.1"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 7271604224,
    "CFBundleShortVersionString" : "2.1.1",
    "CFBundleIdentifier" : "com.apple.HIToolbox",
    "size" : 3358720,
    "uuid" : "d800278b-4e6c-3032-b56f-027a938a51d6",
    "path" : "\/System\/Library\/Frameworks\/Carbon.framework\/Versions\/A\/Frameworks\/HIToolbox.framework\/Versions\/A\/HIToolbox",
    "name" : "HIToolbox"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 7107682304,
    "size" : 582996,
    "uuid" : "bd993f39-c902-37d6-8bd8-6d827c7f121e",
    "path" : "\/usr\/lib\/dyld",
    "name" : "dyld"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 7111184384,
    "size" : 53248,
    "uuid" : "46d35233-a051-3f4f-bba4-ba56dddc4d1a",
    "path" : "\/usr\/lib\/system\/libsystem_pthread.dylib",
    "name" : "libsystem_pthread.dylib"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 7110946816,
    "size" : 237544,
    "uuid" : "42f503e2-9273-360a-a086-c1b19bbd3962",
    "path" : "\/usr\/lib\/system\/libsystem_kernel.dylib",
    "name" : "libsystem_kernel.dylib"
  }
],
  "sharedCache" : {
  "base" : 7107018752,
  "size" : 3551805440,
  "uuid" : "7d9faa84-5c6b-3ef4-9379-faba64346673"
},
  "vmSummary" : "ReadOnly portion of Libraries: Total=1.2G resident=0K(0%) swapped_out_or_unallocated=1.2G(100%)\nWritable regions: Total=1.5G written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=1.5G(100%)\n\n                                VIRTUAL   REGION \nREGION TYPE                        SIZE    COUNT (non-coalesced) \n===========                     =======  ======= \nAccelerate framework               128K        1 \nActivity Tracing                   256K        1 \nCG image                           112K        6 \nColorSync                          496K       25 \nCoreAnimation                      688K       28 \nCoreGraphics                        48K        3 \nCoreServices                       256K        1 \nCoreUI image data                 1648K       13 \nFoundation                          16K        1 \nKernel Alloc Once                   32K        1 \nMALLOC                           277.5M       58 \nMALLOC guard page                  288K       14 \nMALLOC_MEDIUM (reserved)         840.0M        7         reserved VM address space (unallocated)\nMALLOC_NANO (reserved)           384.0M        1         reserved VM address space (unallocated)\nSQLite page cache                  128K        1 \nSTACK GUARD                       56.2M       10 \nStack                             12.8M       10 \nVM_ALLOCATE                        112K        7 \n__AUTH                             855K      209 \n__AUTH_CONST                      17.6M      392 \n__CTF                               824        1 \n__DATA                            6761K      381 \n__DATA_CONST                      17.8M      396 \n__DATA_DIRTY                       987K      136 \n__FONT_DATA                        2352        1 \n__LINKEDIT                       802.1M        4 \n__OBJC_RO                         66.3M        1 \n__OBJC_RW                         2011K        1 \n__TEXT                           376.9M      415 \ndyld private memory                272K        2 \nlibnetwork                         128K        8 \nmapped file                       80.0M       28 \nshared memory                      864K       13 \n===========                     =======  ======= \nTOTAL                              2.9G     2176 \nTOTAL, minus reserved VM space     1.7G     2176 \n",
  "legacyInfo" : {
  "threadTriggered" : {
    "queue" : "com.apple.main-thread"
  }
},
  "logWritingSignature" : "cc6941b62c136f20b2f90c2a5f8efcf4c7cd7428",
  "trialInfo" : {
  "rollouts" : [
    {
      "rolloutId" : "62c74108bcb0435c2153f963",
      "factorPackIds" : {
        "SIRI_TEXT_TO_SPEECH" : "64810e3fd0f2cd4ea9c0d6b9"
      },
      "deploymentId" : 240000226
    },
    {
      "rolloutId" : "5f72dc58705eff005a46b3a9",
      "factorPackIds" : {

      },
      "deploymentId" : 240000015
    }
  ],
  "experiments" : [
    {
      "treatmentId" : "c28e4ee6-1b08-4f90-8e05-2809e78310a3",
      "experimentId" : "6317d2003d24842ff850182a",
      "deploymentId" : 400000013
    },
    {
      "treatmentId" : "6dd670af-0633-45e4-ae5f-122ae4df02be",
      "experimentId" : "64406ba83deb637ac8a04419",
      "deploymentId" : 900000005
    }
  ]
}
}
starbugs commented 1 year ago

Thank you!

To add some context for future reference: I was able to reproduce this by doing the following:

  1. Have only a single Xcode window open and Xcode as focused application
  2. Minimize said Xcode window
  3. Cmd+Tab to another application
  4. Cmd+Tab back to Xcode
Screenshot 2023-06-22 at 08 36 13

A PR fixing this is on the way.

Demircivi commented 1 year ago

Aha! Thank you for fixing this! Based on your reproduction methods, I can now precisely crash the application 😂 I am waiting for #116 to be merged.

starbugs commented 1 year ago

Some more context (which nobody needs to read). I would otherwise note and bookmark this and never find it again:

The reason this is even safe in WakaTime at the moment with the force cast moved into the if let is the following line in our AXUIElement extension's getValue() function:

https://github.com/wakatime/macos-wakatime/blob/9293c49169091b328652181890b8f9928de0a40a/WakaTime/Watcher.swift#L317

Beyond this, there's some Swift internals involved. It boils down to CFTypeRef being a typealias for AnyObject. And Any/AnyObject vs. nil is a bit weird in Swift, especially when it comes to opaque CoreFoundation types. See the accepted answer in this StackOverflow post.