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

Copying nativeImage to clipboard after crop is crashing program #8017

Closed
aouerfelli opened this Issue Nov 18, 2016 · 1 comment

Comments

Projects
None yet
3 participants
@aouerfelli
Copy link

aouerfelli commented Nov 18, 2016

  • Electron version: 1.4.7
  • Operating system: Windows 10 (x64)

Expected behavior

The image should copy to the clipboard properly after a crop.

Actual behavior

Before cropping, the image can be copied to the clipboard without any issues. After a crop, copying the image will crash the program and will not be copied to the clipboard. Same behavior on Main and Render processes.

How to reproduce

I have the following code on a render file, but putting it in the main file will yield similar results.

const {nativeImage, clipboard} = require('electron');

// 4592x3056 image (https://images.unsplash.com/photo-1431512284068-4c4002298068)
let image = nativeImage.createFromPath('./test.jpg');

// Works (copies as intended)
clipboard.writeImage(image);

image = image.crop({
    x: 20,
    y: 40,
    width: 400,
    height: 200
});

// Doesn't work (crashes)
clipboard.writeImage(image);
@kevinsawicki

This comment has been minimized.

Copy link
Contributor

kevinsawicki commented Nov 21, 2016

Here is the stack trace for this crash:

memcpy() Line 135
ui::ClipboardWin::WriteBitmap(const SkBitmap & bitmap) Line 799
ui::Clipboard::DispatchObject(ui::Clipboard::ObjectType type, const std::vector<std::vector<char,std::allocator<char> >,std::allocator<std::vector<char,std::allocator<char> > > > & params) Line 118
ui::ClipboardWin::WriteObjects(ui::ClipboardType type, const std::map<int,std::vector<std::vector<char,std::allocator<char> >,std::allocator<std::vector<char,std::allocator<char> > > >,std::less<int>,std::allocator<std::pair<int const ,std::vector<std::vector<char,std::allocator<char> >,std::allocator<std::vector<char,std::allocator<char> > > > > > > & objects) Line 718
ui::ScopedClipboardWriter::~ScopedClipboardWriter() Line 24
atom::api::Clipboard::WriteImage(const gfx::Image & image, mate::Arguments * args) Line 151
mate::internal::Invoker<mate::internal::IndicesHolder<0,1>,gfx::Image const & __ptr64,mate::Arguments * __ptr64>::DispatchToCallback(base::Callback<void __cdecl(gfx::Image const &,mate::Arguments *),1> callback) Line 202
mate::internal::Dispatcher<void __cdecl(gfx::Image const & __ptr64,mate::Arguments * __ptr64)>::DispatchToCallback(const v8::FunctionCallbackInfo<v8::Value> & info) Line 236

@stale stale bot added the wontfix label Mar 15, 2017

@zeke zeke removed wontfix labels Mar 15, 2017

ferreus added a commit to ferreus/electron that referenced this issue Jun 29, 2017

@zcbenz zcbenz closed this in 5f2dd2e Sep 12, 2017

zcbenz added a commit that referenced this issue Sep 12, 2017

Merge pull request #9896 from ferreus/dev/vladimir_8017
Fix #8017: Crash copying cropped image to clipboard
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment