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 startDrag crash on macOS with empty image #8511

Merged
merged 4 commits into from
Jan 27, 2017
Merged

Conversation

kevinsawicki
Copy link
Contributor

@kevinsawicki kevinsawicki commented Jan 25, 2017

Currently webContents.startDrag will crash on macOS if called with an empty image.

This pull request updates webContents.startDrag to check for a non-empty image on macOS and raise an error when they happen.

Noticed this while trying to reproduce #8445

Crash report:

Crashing on exception: CALayer position contains NaN: [nan nan]

Application Specific Backtrace 1:
0   CoreFoundation                      0x00007fffc2d1de7b __exceptionPreprocess + 171
1   libobjc.A.dylib                     0x00007fffd7907cad objc_exception_throw + 48
2   CoreFoundation                      0x00007fffc2d9c99d +[NSException raise:format:] + 205
3   QuartzCore                          0x00007fffc8ad7f48 _ZN2CA5Layer12set_positionERKNS_4Vec2IdEEb + 152
4   QuartzCore                          0x00007fffc8ad80bd -[CALayer setPosition:] + 44
5   HIToolbox                           0x00007fffc2260f95 _ZL20UpdateLayerPositionsP14OpaqueCoreDrag + 662
6   HIToolbox                           0x00007fffc248f752 _Z29UnflockAnimationTimerCallbackP16__CFRunLoopTimerPv + 784
7   CoreFoundation                      0x00007fffc2c9d244 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20
8   CoreFoundation                      0x00007fffc2c9cecf __CFRunLoopDoTimer + 1071
9   CoreFoundation                      0x00007fffc2c9ca2a __CFRunLoopDoTimers + 298
10  CoreFoundation                      0x00007fffc2c943e1 __CFRunLoopRun + 2065
11  CoreFoundation                      0x00007fffc2c93974 CFRunLoopRunSpecific + 420
12  CoreFoundation                      0x00007fffc2cf5da5 CFMessagePortSendRequest + 965
13  HIServices                          0x00007fffc19a0b56 SendDragIPCMessage + 540
14  HIServices                          0x00007fffc199e011 CoreDragMessageHandler + 1321
15  CoreFoundation                      0x00007fffc2d34486 __CFMessagePortPerform + 598
16  CoreFoundation                      0x00007fffc2c9c6c9 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 41
17  CoreFoundation                      0x00007fffc2c9c641 __CFRunLoopDoSource1 + 465
18  CoreFoundation                      0x00007fffc2c94525 __CFRunLoopRun + 2389
19  CoreFoundation                      0x00007fffc2c93974 CFRunLoopRunSpecific + 420
20  HIToolbox                           0x00007fffc221fa5c RunCurrentEventLoopInMode + 240
21  HIToolbox                           0x00007fffc221f891 ReceiveNextEventCommon + 432
22  HIToolbox                           0x00007fffc221f6c6 _BlockUntilNextEventMatchingListInModeWithFilter + 71
23  AppKit                              0x00007fffc07c55b4 _DPSNextEvent + 1120
24  AppKit                              0x00007fffc0f3fd6b -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 2789
25  AppKit                              0x00007fffc0a66012 NSCoreDragCGEventBlockingProc + 175
26  HIServices                          0x00007fffc1997ccc SampleMouseAndKeyboard + 145
27  HIServices                          0x00007fffc19979b1 DragInApplication + 53
28  HIServices                          0x00007fffc199696c CoreDragStartDragging + 486
29  AppKit                              0x00007fffc0a630cc -[NSCoreDragManager _dragUntilMouseUp:accepted:] + 1048
30  AppKit                              0x00007fffc0a60056 -[NSCoreDragManager dragImage:fromWindow:at:offset:event:pasteboard:source:slideBack:] + 1193
31  AppKit                              0x00007fffc0a5fb9c -[NSWindow(NSDrag) dragImage:at:offset:event:pasteboard:source:slideBack:] + 135
32  Electron Framework                  0x00000001044ba92e _ZN4atom13DragFileItemsERKNSt3__16vectorIN4base8FilePathENS0_9allocatorIS3_EEEERKN3gfx5ImageEP6NSView + 510
Thread 0 Crashed:: CrBrowserMain  Dispatch queue: com.apple.main-thread
0   libbase.dylib                 	0x0000000111474df1 base::debug::BreakDebugger() + 17
1   libbase.dylib                 	0x000000011149792f logging::LogMessage::~LogMessage() + 1391
2   libgfx.dylib                  	0x0000000115f5b957 gfx::Image::ToNSImage() const + 71
3   com.github.electron.framework 	0x000000010ef447a0 atom::DragFileItems(std::__1::vector<base::FilePath, std::__1::allocator<base::FilePath> > const&, gfx::Image const&, NSView*) + 384 (drag_util_mac.mm:49)
4   com.github.electron.framework 	0x000000010edfc6f5 atom::api::WebContents::StartDrag(mate::Dictionary const&, mate::Arguments*) + 2341 (atom_api_web_contents.cc:1338)

@kevinsawicki kevinsawicki force-pushed the start-drag-crash branch 4 times, most recently from e798b96 to 8c00527 Compare January 26, 2017 18:59
@kevinsawicki kevinsawicki merged commit 6e2f977 into master Jan 27, 2017
@kevinsawicki kevinsawicki deleted the start-drag-crash branch January 27, 2017 01:10
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