Merge pull request #10162 from electron/native-image-crashes
Fix crashes due to using Debug version of libc++
This commit is contained in:
commit
761eca052a
4 changed files with 19 additions and 11 deletions
|
@ -268,11 +268,10 @@ v8::Local<v8::Value> NativeImage::ToPNG(mate::Arguments* args) {
|
|||
|
||||
const SkBitmap bitmap =
|
||||
image_.AsImageSkia().GetRepresentation(scale_factor).sk_bitmap();
|
||||
std::unique_ptr<std::vector<unsigned char>> encoded(
|
||||
new std::vector<unsigned char>());
|
||||
gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, false, encoded.get());
|
||||
const char* data = reinterpret_cast<char*>(encoded->data());
|
||||
size_t size = encoded->size();
|
||||
std::vector<unsigned char> encoded;
|
||||
gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, false, &encoded);
|
||||
const char* data = reinterpret_cast<char*>(encoded.data());
|
||||
size_t size = encoded.size();
|
||||
return node::Buffer::Copy(args->isolate(), data, size).ToLocalChecked();
|
||||
}
|
||||
|
||||
|
@ -292,6 +291,8 @@ v8::Local<v8::Value> NativeImage::ToBitmap(mate::Arguments* args) {
|
|||
v8::Local<v8::Value> NativeImage::ToJPEG(v8::Isolate* isolate, int quality) {
|
||||
std::vector<unsigned char> output;
|
||||
gfx::JPEG1xEncodedDataFromImage(image_, quality, &output);
|
||||
if (output.empty())
|
||||
return node::Buffer::New(isolate, 0).ToLocalChecked();
|
||||
return node::Buffer::Copy(
|
||||
isolate,
|
||||
reinterpret_cast<const char*>(&output.front()),
|
||||
|
|
|
@ -56,7 +56,8 @@ struct V8FunctionInvoker<v8::Local<v8::Value>(ArgTypes...)> {
|
|||
v8::Local<v8::Context> context = holder->CreationContext();
|
||||
v8::Context::Scope context_scope(context);
|
||||
std::vector<v8::Local<v8::Value>> args { ConvertToV8(isolate, raw)... };
|
||||
v8::Local<v8::Value> ret(holder->Call(holder, args.size(), &args.front()));
|
||||
v8::Local<v8::Value> ret(holder->Call(
|
||||
holder, args.size(), args.empty() ? nullptr : &args.front()));
|
||||
return handle_scope.Escape(ret);
|
||||
}
|
||||
};
|
||||
|
@ -76,7 +77,8 @@ struct V8FunctionInvoker<void(ArgTypes...)> {
|
|||
v8::Local<v8::Context> context = holder->CreationContext();
|
||||
v8::Context::Scope context_scope(context);
|
||||
std::vector<v8::Local<v8::Value>> args { ConvertToV8(isolate, raw)... };
|
||||
holder->Call(holder, args.size(), &args.front());
|
||||
holder->Call(
|
||||
holder, args.size(), args.empty() ? nullptr : &args.front());
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -97,8 +99,8 @@ struct V8FunctionInvoker<ReturnType(ArgTypes...)> {
|
|||
v8::Context::Scope context_scope(context);
|
||||
std::vector<v8::Local<v8::Value>> args { ConvertToV8(isolate, raw)... };
|
||||
v8::Local<v8::Value> result;
|
||||
auto maybe_result =
|
||||
holder->Call(context, holder, args.size(), &args.front());
|
||||
auto maybe_result = holder->Call(
|
||||
context, holder, args.size(), args.empty() ? nullptr : &args.front());
|
||||
if (maybe_result.ToLocal(&result))
|
||||
Converter<ReturnType>::FromV8(isolate, result, &ret);
|
||||
return ret;
|
||||
|
|
|
@ -62,16 +62,17 @@
|
|||
if (query.invert) mocha.invert();
|
||||
|
||||
// Read all test files.
|
||||
var walker = require('walkdir').walk(require('path').dirname(__dirname), {
|
||||
var walker = require('walkdir').walk(path.dirname(__dirname), {
|
||||
no_recurse: true
|
||||
});
|
||||
|
||||
walker.on('file', function(file) {
|
||||
if (/-spec\.js$/.test(file))
|
||||
if (/-spec\.js$/.test(file) && !file.includes('api-crash-reporter-spec.js'))
|
||||
mocha.addFile(file);
|
||||
});
|
||||
|
||||
walker.on('end', function() {
|
||||
mocha.addFile(path.resolve(__dirname, '..', 'api-crash-reporter-spec.js'))
|
||||
var runner = mocha.run(function() {
|
||||
if (isCi && runner.hasOnly) {
|
||||
try {
|
||||
|
|
|
@ -141,6 +141,10 @@ app.on('ready', function () {
|
|||
})
|
||||
if (chosen === 0) window.destroy()
|
||||
})
|
||||
window.webContents.on('crashed', function () {
|
||||
console.error('Renderer process crashed')
|
||||
process.exit(1)
|
||||
})
|
||||
|
||||
// For session's download test, listen 'will-download' event in browser, and
|
||||
// reply the result to renderer for verifying
|
||||
|
|
Loading…
Reference in a new issue