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

[PLAT-8918] Mac Catalyst: fix crash in addBreadcrumbForTableViewNotification: #1485

Merged
merged 2 commits into from Sep 20, 2022

Conversation

nickdowell
Copy link
Contributor

@nickdowell nickdowell commented Sep 20, 2022

Goal

Fix a crash in -[BSGNotificationBreadcrumbs addBreadcrumbForTableViewNotification:]

Bug report: #1484

Error:
-[SCTTableView indexPathForSelectedRow]: unrecognized selector sent to instance 0x7f86f6095400

0   CoreFoundation                      0x000000019f4d51a8 __exceptionPreprocess + 240
1   libobjc.A.dylib                     0x000000019f21fe04 objc_exception_throw + 60
2   CoreFoundation                      0x000000019f568f4c -[NSObject(NSObject) __retain_OA] + 0
3   CoreFoundation                      0x000000019f434554 ___forwarding___ + 1764
4   CoreFoundation                      0x000000019f433db0 _CF_forwarding_prep_0 + 96
5   Vectornator                         0x00000001048fc3e8 -[BSGNotificationBreadcrumbs addBreadcrumbForTableViewNotification:] + 96
6   CoreFoundation                      0x000000019f44951c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 28
7   CoreFoundation                      0x000000019f4edc18 ___CFXRegistrationPost_block_invoke + 52
8   CoreFoundation                      0x000000019f4edb84 _CFXRegistrationPost + 456
9   CoreFoundation                      0x000000019f4181c0 _CFXNotificationPost + 732
10  Foundation                          0x00000001a02ddc98 -[NSNotificationCenter postNotificationName:object:userInfo:] + 96
11  AppKit                              0x00000001a20e1f8c -[NSTableView _sendSelectionChangedNotificationForRows:columns:] + 244
12  AppKit                              0x00000001a20e143c -[NSTableView _doSelectIndexes:byExtendingSelection:indexType:funnelThroughSingleIndexVersion:] + 1788
13  AppKit                              0x00000001a20e0d1c -[NSTableView selectRowIndexes:byExtendingSelection:] + 136
14  Shortcut                            0x00000001d6ad7390 -[SCTMenuView mouseMoved:] + 388
15  AppKit                              0x00000001a21b11d4 forwardMethod + 200
16  AppKit                              0x00000001a21b11d4 forwardMethod + 200
17  AppKit                              0x00000001a21b11d4 forwardMethod + 200
18  AppKit                              0x00000001a21b11d4 forwardMethod + 200
19  AppKit                              0x00000001a21b0f18 -[NSTextView mouseMoved:] + 684
20  AppKit                              0x00000001a212be88 -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 5908
21  AppKit                              0x00000001a212a50c -[NSWindow(NSEventRouting) sendEvent:] + 348
22  AppKit                              0x00000001a28d970c NSMenuWindowManagerMenuItemCarbonEventHandler + 4160
23  HIToolbox                           0x00000001a806a6c8 _ZL23DispatchEventToHandlersP14EventTargetRecP14OpaqueEventRefP14HandlerCallRec + 1084
24  HIToolbox                           0x00000001a8069b4c _ZL30SendEventToEventTargetInternalP14OpaqueEventRefP20OpaqueEventTargetRefP14HandlerCallRec + 356
25  HIToolbox                           0x00000001a807fe50 SendEventToEventTarget + 40
26  HIToolbox                           0x00000001a80aa638 _ZL29ToolboxEventDispatcherHandlerP25OpaqueEventHandlerCallRefP14OpaqueEventRefPv + 2520
27  HIToolbox                           0x00000001a806ab14 _ZL23DispatchEventToHandlersP14EventTargetRecP14OpaqueEventRefP14HandlerCallRec + 2184
28  HIToolbox                           0x00000001a8069b4c _ZL30SendEventToEventTargetInternalP14OpaqueEventRefP20OpaqueEventTargetRefP14HandlerCallRec + 356
29  HIToolbox                           0x00000001a807fe50 SendEventToEventTarget + 40
30  HIToolbox                           0x00000001a80fb3bc _ZL19IsUserStillTrackingP14MenuSelectDataPh + 3604
31  HIToolbox                           0x00000001a82392bc _ZL15TrackMenuCommonR14MenuSelectDataPhP13SelectionDataP10MenuResultS5_ + 1260
32  HIToolbox                           0x00000001a8106054 _ZL14MenuSelectCoreP8MenuData5PointdjPP13OpaqueMenuRefPt + 348
33  HIToolbox                           0x00000001a8105e48 _HandleMenuSelection2 + 416
34  AppKit                              0x00000001a21576f0 _NSHandleCarbonMenuEvent + 300
35  AppKit                              0x00000001a21574d0 _DPSEventHandledByCarbon + 68
36  AppKit                              0x00000001a1fb95b4 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 3280
37  AppKit                              0x00000001a1faafe0 -[NSApplication run] + 596
38  AppKit                              0x00000001a1f7c6fc NSApplicationMain + 1132
39  AppKit                              0x00000001a2252640 +[NSWindow _savedFrameFromString:] + 0
40  UIKitMacHelper                      0x00000001b4d173c0 UINSApplicationMain + 1276
41  UIKitCore                           0x00000001c74b4c2c UIApplicationMain + 164
42  Vectornator                         0x000000010484ee04 $s11Vectornator15ApplicationMainV4mainyyFZTf4d_n + 224
43  Vectornator                         0x00000001043502c0 main + 12
44  dyld                                0x0000000108c4908c start + 520

Analysis

The crash was caused by -[BSGNotificationBreadcrumbs addBreadcrumbForTableViewNotification:] being passed a (subclass of) NSTableView when compiling for Mac Catalyst.

This method expects a UITableView to be passed when compiling for TARGET_OS_IOS || TARGET_OS_TV.

BSGNotificationBreadcrumbs was erroneously listening for NSTableViewSelectionDidChangeNotification instead of UITableViewSelectionDidChangeNotification because BSG_HAVE_APPKIT is true when compiling for Mac Catalyst.

This bug was introduced by #1361 (watchOS support) in v6.18.0.

Changeset

Makes automaticBreadcrumbTableItemEvents use TARGET_OS_IOS || TARGET_OS_TV to determine which notification to listen for.

Removes BSG_HAVE_APPKIT and related macros to avoid this confusion in the future.

Tidies up some imports.

Testing

Manually reproduced issue in examples/objective-c-ios and verified the fix.

@github-actions
Copy link

Bugsnag.framework binary size did not change - 705,368 bytes

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  [ = ]       0  [ = ]       0    TOTAL

Generated by 🚫 Danger

@nickdowell nickdowell merged commit 78cae69 into next Sep 20, 2022
@nickdowell nickdowell deleted the nickdowell/fix-mac-catalyst-crash branch September 20, 2022 15:23
@Czajnikowski
Copy link

Thanks for such a blazingly fast reaction guys 🙌 Do you have any idea of when a new version will be released?

@nickdowell
Copy link
Contributor Author

Thanks for such a blazingly fast reaction guys 🙌 Do you have any idea of when a new version will be released?

A new version will be released later today 👍

@nickdowell nickdowell mentioned this pull request Sep 21, 2022
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.

None yet

3 participants