Skip to content

Enhancement: compatibility with Electron 21 will require copying all memory Buffers, will have performance cost #3384

@Julusian

Description

@Julusian

Possible 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 by npm 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. electron/electron#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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions