electron / electron

:electron: Build cross-platform desktop apps with JavaScript, HTML, and CSS
https://electronjs.org
MIT License
112.78k stars 15.12k forks source link

[Bug]: Electron main process crash during any navigator.serial requests on MacOS in development mode #41220

Open ottomen opened 5 months ago

ottomen commented 5 months ago

Preflight Checklist

Electron Version

28.1.0

What operating system are you using?

macOS

Operating System Version

MacOS: 13.2.1 (22D68)

What arch are you using?

x64

Last Known Working Electron version

No response

Expected Behavior

Electron process should not be crashed during the Serial port operations on MacOS in development mode running electron .

Actual Behavior

Error: Failed to execute 'requestPort' on 'Serial': No port selected by the user. :: [0202/091640.098527:WARNING:crash_report_exception_handler.cc(235)] UniversalExceptionRaise: (os/kern) failure (5) /Users/user/Work/web-ui/electron/node_modules/electron/dist/Electron.app/Contents/MacOS/Electron exited with signal SIGABRT

Testcase Gist URL

No response

Additional Information

Processor: 2.6 GHz 6-Core Intel Core i7 RAM: 16 GB 2667 MHz DDR4 MacOS: 13.2.1 (22D68)

const BrowserWindowConstructorOptions = {
  autoHideMenuBar: true,
  show: false,
  width: 1280,
  height: 720,
  minWidth: 640,
  minHeight: 480,
  webPreferences: {
    contextIsolation: true,
    nodeIntegration: false,
    sandbox: true,
    webSecurity: true,
    allowRunningInsecureContent: false,
    experimentalFeatures: false,
    spellcheck: false,
    v8CacheOptions: 'bypassHeatCheck',
    preload: path.join(__dirname, 'preload.js'),
  },
}

And it works fine on Windows development and production builded modes.

electron-issue-triage[bot] commented 5 months ago

Hello @ottomen. Thanks for reporting this and helping to make Electron better!

Would it be possible for you to make a standalone testcase with only the code necessary to reproduce the issue? For example, Electron Fiddle is a great tool for making small test cases and makes it easy to publish your test case to a gist that Electron maintainers can use.

Stand-alone test cases make fixing issues go more smoothly: it ensure everyone's looking at the same issue, it removes all unnecessary variables from the equation, and it can also provide the basis for automated regression tests.

Now adding the https://github.com/electron/electron/labels/blocked%2Fneed-repro label for this reason. After you make a test case, please link to it in a followup comment. This issue will be closed in 10 days if the above is not addressed.

ottomen commented 5 months ago

Electron Fiddle doesn't show the issue, first of all because there is a mainWindow.loadFile('index.html') but we use mainWindow.loadURL('http://localhost:3000');. in the project. This is minor thing, but still, it Fiddle is a tool over the code, that is not the real environment, that can't be the reference for all issues.

I've made a repo with a simplified version, similar to gist: https://github.com/ottomen/electron-serial-issue-demo that shows the problem. Can you check it, please?

Thank you!

ottomen commented 4 months ago

Any updates?

codebytere commented 2 months ago

I ran the repro and could not reproduce the issue. it logs Serial port open request to console and does not crash.

Beyond that, the verbiage in the above comment:

Would it be possible for you to make a standalone testcase with only the code necessary to reproduce the issue? For example, Electron Fiddle is a great tool for making small test cases and makes it easy to publish your test case to a gist that Electron maintainers can use.

does not prescriptively require Electron Fiddle; it requires any standalone repro. We did not position it as "the reference for all issues", we simply suggested it as for many issues reported here it is sufficient.

ottomen commented 2 months ago

Yes, but I have a crash. It happens on the particular OS that I mentioned. It happens in the Dev mode.

ottomen commented 2 months ago

Update. I've installed Sonoma 14.4.1 on Mac, and the issue is gone. I haven't updated the Electron version, so it seems it was a problem with a specific Mac OS 13.2.1