GithubHelp home page GithubHelp logo

Comments (8)

SilentRush avatar SilentRush commented on April 28, 2024 5

I found a work around, it appears the ref-napi.reinterpretUntilZeros function is broken in electron 8.

I changed the following:

const windowTextBufferClean = ref.reinterpretUntilZeros(windowTextBuffer, wchar.size);
to
const dirtyTitle = wchar.toString(windowTextBuffer);
const windowTitle = dirtyTitle.replace(/\0/g, '');

const processFileNameBufferClean = ref.reinterpretUntilZeros(processFileNameBuffer, wchar.size);
to
const pathDirty = wchar.toString(processFileNameBuffer);
const processPath = pathDirty.replace(/\0/g, '');

from active-win.

Antelope-IT avatar Antelope-IT commented on April 28, 2024 3

@sindresorhus Hi, Now that Electron v7 is out of support (V10 has been released), please can we have a fix for this bug so that projects with dependencies on this library can at least be upgraded to Electron v8? Pull requests have been prepared, a bug has been raised and acknowledged on Electron for v8. There is little possibility of this being resolved in Electron in the short term and less possibility that the issues preventing us from upgrading to Electron v9 and Electron v10 will be resolved in the short term either. Is there anything else preventing this issue from being resolved or is there an alternative path we should follow?

from active-win.

Antelope-IT avatar Antelope-IT commented on April 28, 2024 2

If anyone wants to see this fixed here, please open an issue on Electron first. I'm not going to merge a fix and have to maintain that if people cannot even bother to open an issue to ensure it will eventually be fixed in Electron.

Previous PR attempts:

I don't know if this is enough and if anyone can add to it then please do but with my limited understanding I have tried to open an issue on Electron electron/electron#24981

from active-win.

tkainrad avatar tkainrad commented on April 28, 2024 1

For anyone that has this problem and is not sure how to best patch a library until a fix is available. I did the following:

  1. Install the patch_package module
  2. Apply the changes described above by @SilentRush
    • Be careful, you need to replace also the two lines with the reinterpretUntilZeros calls, but also the line below with the assignment
  3. Run npx patch-package active-win
  4. Add "postinstall": "npx patch-package" to your package.json

This works well also with deployment pipelines, e.g. GitHub Actions and can be removed easily once there is a fix either from the Electron project or the active-win project.
Btw, thanks for this amazing library @sindresorhus !

from active-win.

SilentRush avatar SilentRush commented on April 28, 2024

Within windows.js the following line is causing the crash.

const windowTextBufferClean = ref.reinterpretUntilZeros(windowTextBuffer, wchar.size);

from active-win.

EntwistleOx avatar EntwistleOx commented on April 28, 2024

I found a work around, it appears the ref-napi.reinterpretUntilZeros function is broken in electron 8.

I changed the following:

const windowTextBufferClean = ref.reinterpretUntilZeros(windowTextBuffer, wchar.size);
to
const dirtyTitle = wchar.toString(windowTextBuffer);
const windowTitle = dirtyTitle.replace(/\0/g, '');

const processFileNameBufferClean = ref.reinterpretUntilZeros(processFileNameBuffer, wchar.size);
to
const pathDirty = wchar.toString(processFileNameBuffer);
const processPath = pathDirty.replace(/\0/g, '');

same problem here, your approach save me, thanks!

from active-win.

sindresorhus avatar sindresorhus commented on April 28, 2024

If anyone wants to see this fixed here, please open an issue on Electron first. I'm not going to merge a fix and have to maintain that if people cannot even bother to open an issue to ensure it will eventually be fixed in Electron.

Previous PR attempts:

from active-win.

tkainrad avatar tkainrad commented on April 28, 2024

The patch I described in my previous comment is no longer necessary with Electron 11 and active-win 7.1. With this setup, everything works out of the box. I think this issue can possibly be closed.

from active-win.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.