-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ref(profiling) Fix electron crash #14216
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
c82add5
ref(profiling) Fix electron crash
JonasBa baef45a
test(profiling) add electron e2e test
JonasBa d41cdb1
fixup! test(profiling) add electron e2e test
JonasBa 9a4428c
remove yarn lockfile
JonasBa 41f3b52
test: Install dependencies in e2e test
JonasBa 4f136f5
try force install
JonasBa 5ddb1b6
try pnpm
JonasBa 7b3b666
point to binary directly
JonasBa 77db181
install e2e deps
JonasBa 4072ec0
Merge branch 'develop' into jb/profiling/electron-binaries
JonasBa fac3d34
fix correct path
JonasBa ebc5216
bump runner to see if it comes w newer deps
JonasBa ed37d35
test xvfb
JonasBa f2d27b0
remove obsolete package
JonasBa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
dev-packages/e2e-tests/test-applications/node-profiling/__tests__/electron.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const process = require('process'); | ||
const { test, expect, _electron: electron } = require('@playwright/test'); | ||
|
||
test('an h1 contains hello world"', async () => { | ||
const electronApp = await electron.launch({ | ||
args: ['./index.electron.js'], | ||
process: { | ||
env: { | ||
...process.env, | ||
}, | ||
}, | ||
}); | ||
|
||
// Wait for the first BrowserWindow to open | ||
const window = await electronApp.firstWindow(); | ||
|
||
// Check for the presence of an h1 element with the text "hello" | ||
const headerElement = await window.$('h1'); | ||
const headerText = await headerElement.textContent(); | ||
expect(headerText).toBe('Hello From Profiled Electron App'); | ||
|
||
// Close the app | ||
await electronApp.close(); | ||
}); |
54 changes: 54 additions & 0 deletions
54
dev-packages/e2e-tests/test-applications/node-profiling/index.electron.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Modules to control application life and create native browser window | ||
const { app, BrowserWindow } = require('electron'); | ||
const Sentry = require('@sentry/electron/main'); | ||
const path = require('node:path'); | ||
|
||
Sentry.init({ | ||
dsn: 'https://7fa19397baaf433f919fbe02228d5470@o1137848.ingest.sentry.io/6625302', | ||
debug: true, | ||
tracesSampleRate: 1.0, | ||
}); | ||
|
||
// Hog the cpu for a second | ||
function block() { | ||
const start = Date.now(); | ||
while (start + 1000 > Date.now()) {} | ||
} | ||
|
||
const createWindow = () => { | ||
block(); | ||
// Create the browser window. | ||
const mainWindow = new BrowserWindow({ | ||
width: 800, | ||
height: 600, | ||
webPreferences: { | ||
preload: path.join(__dirname, 'preload.js'), | ||
}, | ||
}); | ||
|
||
// and load the index.html of the app. | ||
mainWindow.loadFile('index.html'); | ||
block(); | ||
}; | ||
|
||
// This method will be called when Electron has finished | ||
// initialization and is ready to create browser windows. | ||
// Some APIs can only be used after this event occurs. | ||
app.whenReady().then(() => { | ||
Sentry.profiler.startProfiler(); | ||
createWindow(); | ||
Sentry.profiler.stopProfiler(); | ||
|
||
app.on('activate', () => { | ||
// On macOS it's common to re-create a window in the app when the | ||
// dock icon is clicked and there are no other windows open. | ||
if (BrowserWindow.getAllWindows().length === 0) createWindow(); | ||
}); | ||
}); | ||
|
||
// Quit when all windows are closed, except on macOS. There, it's common | ||
// for applications and their menu bar to stay active until the user quits | ||
// explicitly with Cmd + Q. | ||
app.on('window-all-closed', () => { | ||
if (process.platform !== 'darwin') app.quit(); | ||
}); |
6 changes: 6 additions & 0 deletions
6
dev-packages/e2e-tests/test-applications/node-profiling/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<body> | ||
<h1>Hello From Profiled Electron App</h1> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unclear why using the options signature causes this to sigabrt, but this will do too.