Enhancement: compatibility with Electron 21 will require copying all memory Buffers, will have performance cost
See original GitHub issuePossible bug
Is this a possible bug in a feature of sharp, unrelated to installation?
- Running
npm install sharp
completes without error. - Running
node -e "require('sharp')"
completes without error.
Are you using the latest version of sharp?
- I am using the latest version of
sharp
as reported bynpm view sharp dist-tags.latest
.
What is the output of running npx envinfo --binaries --system --npmPackages=sharp --npmGlobalPackages=sharp
?
System:
OS: Linux 5.15 Ubuntu 22.04.1 LTS 22.04.1 LTS (Jammy Jellyfish)
CPU: (8) x64 Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
Memory: 9.20 GB / 31.23 GB
Container: Yes
Shell: 5.1.16 - /bin/bash
Binaries:
Node: 16.17.0 - /run/user/1000/fnm_multishells/799191_1664035140689/bin/node
Yarn: 1.22.19 - /run/user/1000/fnm_multishells/799191_1664035140689/bin/yarn
npm: 8.15.0 - /run/user/1000/fnm_multishells/799191_1664035140689/bin/npm
npmPackages:
sharp: ^0.31.0 => 0.31.0
What are the steps to reproduce?
Run sharp with electron 21
What is the expected behaviour?
Sharp should be compatible
Please provide a minimal, standalone code sample, without other dependencies, that demonstrates this problem
{
"dependencies": {
"electron": "^21.0.0-beta.8",
"sharp": "^0.31.0"
},
"scripts": {
"test": "electron main.js"
}
}
const sharp = require('sharp')
const semiTransparentRedPng = sharp({
create: {
width: 48,
height: 48,
channels: 4,
background: { r: 255, g: 0, b: 0, alpha: 0.5 }
}
})
.png()
.toBuffer();
It is important to run the script through electron, and it has to be v21+
Please provide sample image(s) that help explain this problem
This is because of a change electron have made, which breaks compatability for some native modules https://www.electronjs.org/blog/v8-memory-cage
Electron 21 was released on the 27th September, and I have opened an issue to complain about their breakage of the guaranteed stable node-api that electron are doing here. https://github.com/electron/electron/issues/35801
[826378:0924/183534.268000:ERROR:node_bindings.cc(146)] Fatal error in V8: v8_ArrayBuffer_NewBackingStore When the V8 Sandbox is enabled, ArrayBuffer backing stores must be allocated inside the sandbox address space. Please use an appropriate ArrayBuffer::Allocator to allocate these buffers.
Issue Analytics
- State:
- Created a year ago
- Reactions:6
- Comments:14 (7 by maintainers)
Top Results From Across the Web
[Bug]: Electron 21 breaks node-api stability guarantees #35801
Enhancement: compatibility with Electron 21 will require copying all memory Buffers, will have performance cost lovell/sharp#3384.
Read more >How to use Buffer.from in electron 21+ - node.js - Stack Overflow
In Electron 21+, electron is using v8 memory cage. This is a fantastic move forward to reduce various bugs and enable performance of ......
Read more >Electron's blog
Electron 22.0.0 has been released! It includes a new utility process API, updates for Windows 7/8/8.1 support, and upgrades to Chromium 108 ,...
Read more >Optimizing Checkpoints Using NVM as Virtual Memory
Based on these two goals, we propose a remote memory model where applications can allocate, access and copy NVM buffers to local as...
Read more >Resistive Random Access Memory (RRAM): an Overview of ...
Random access memory referred to as RAM can either be volatile or ... meaning there is a need to refresh every few milliseconds....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
v0.31.3 now available with a workaround for the V8 memory cage.
Please remember you’ll need a future version of Electron that provides the patched version of Node.js to take advantage of this.
https://github.com/electron/electron/search?q=09ae62b&type=issues
Commit https://github.com/lovell/sharp/commit/584807b4f5e1b831785c79eef5367f737589f29b adds this and it will be part of v0.31.3.
Please remember you’ll need a version of Electron that provides the patched version of Node.js