Title: feedback: screenshot can contain the feedback form itself, because `getDisplayMedia` is called in the same task that hides the form · Issue #25657 · getsentry/sentry-javascript · GitHub
Open Graph Title: feedback: screenshot can contain the feedback form itself, because `getDisplayMedia` is called in the same task that hides the form · Issue #25657 · getsentry/sentry-javascript
X Title: feedback: screenshot can contain the feedback form itself, because `getDisplayMedia` is called in the same task that hides the form · Issue #25657 · getsentry/sentry-javascript
Description: Is there an existing issue for this? I searched for the symptom and did not find one. Package and version @sentry/browser 11.5.0 (@sentry/feedback 11.5.0), feedbackIntegration({ enableScreenshot: true }). develop and the latest release (...
Open Graph Description: Is there an existing issue for this? I searched for the symptom and did not find one. Package and version @sentry/browser 11.5.0 (@sentry/feedback 11.5.0), feedbackIntegration({ enableScreenshot: t...
X Description: Is there an existing issue for this? I searched for the symptom and did not find one. Package and version @sentry/browser 11.5.0 (@sentry/feedback 11.5.0), feedbackIntegration({ enableScreenshot: t...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/25657
X: @github
Domain: github.com
IPv4 address: 140.82.113.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"feedback: screenshot can contain the feedback form itself, because `getDisplayMedia` is called in the same task that hides the form","articleBody":"## Is there an existing issue for this?\n\nI searched for the symptom and did not find one.\n\n## Package and version\n\n`@sentry/browser` 11.5.0 (`@sentry/feedback` 11.5.0), `feedbackIntegration({ enableScreenshot: true })`.\n`develop` and the latest release (11.8.0) have the same sequence in `useTakeScreenshot.tsx`, as far as I can read it.\n\n## What happens\n\nSometimes the screenshot the user adds in the feedback form is a picture of the page *with the feedback form on top of it*, instead of the page alone. The picture is then sent with the feedback.\n\n## Why\n\nIn `packages/feedback/src/screenshot/components/useTakeScreenshot.tsx` the effect does:\n\n```ts\nonBeforeScreenshot(); // ScreenshotEditor: dialogStyle.display = 'none'\nconst stream = await NAVIGATOR.mediaDevices.getDisplayMedia({ ... preferCurrentTab: true ... });\n```\n\n`onBeforeScreenshot()` only sets `display: none` on the dialog. `getDisplayMedia` is called right after, in the same task, before the browser has painted a frame without the dialog. The tab capture starts from the last frame the compositor produced, so on a busy machine that frame can still be the one with the form in it. The first frame of the video is what `onloadedmetadata` hands to the editor, so the form ends up in the picture.\n\n## Reproduction\n\nA page with a blue 56px bar at the top and the feedback form opened over it. The test clicks \"Add a screenshot\", reads the editor's background canvas and checks that the top 40px are the page's blue bar and not the form.\n\n`app.js` (bundled with `esbuild app.js --bundle --format=esm --outfile=dist/app.js`):\n\n```js\nimport { feedbackIntegration, getFeedback, init } from '@sentry/browser'\n\ninit({\n dsn: 'https://public@example.invalid/1',\n integrations: [feedbackIntegration({ autoInject: false, enableScreenshot: true })],\n})\n\ndocument.getElementById('open').addEventListener('click', async () => {\n const form = await getFeedback().createForm()\n form.appendToDom()\n form.open()\n})\ndocument.documentElement.setAttribute('data-ready', '')\n```\n\n`dist/index.html`:\n\n```html\n\u003c!doctype html>\n\u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n\u003cstyle>\n body { margin: 0; background: #101214; color: #eee; font: 14px system-ui; }\n nav { height: 56px; background: rgb(0, 102, 255); }\n pre { margin: 12px; padding: 8px; background: #000; height: 520px; }\n #open { position: fixed; right: 16px; bottom: 16px; }\n\u003c/style>\n\u003cnav>\u003c/nav>\n\u003cpre>some page content\u003c/pre>\n\u003cbutton id=\"open\">feedback\u003c/button>\n\u003cscript type=\"module\" src=\"/app.js\">\u003c/script>\n```\n\n`repro.spec.ts` (Playwright 1.62.1, Chromium, `--use-fake-ui-for-media-stream`, viewport 390x800):\n\n```ts\nimport { expect, test, type Page } from '@playwright/test'\n\ntest.use({\n viewport: { width: 390, height: 800 },\n launchOptions: { args: ['--use-fake-ui-for-media-stream'] },\n})\n\n/** Headless Chromium hands the capture a frame only when the page paints, so paint one pixel on every poll. */\nasync function repaintCorner(page: Page) {\n await page.evaluate(() => {\n let dot = document.getElementById('corner')\n if (!dot) {\n dot = document.createElement('div')\n dot.id = 'corner'\n dot.style.cssText = 'position:fixed;left:0;top:0;width:1px;height:1px;z-index:2147483647'\n document.body.append(dot)\n }\n dot.style.background = dot.style.background === 'rgb(0, 0, 0)' ? 'rgb(255, 255, 255)' : 'rgb(0, 0, 0)'\n })\n}\n\ntest('the screenshot holds the page, not the feedback form', async ({ page }) => {\n await page.goto('/')\n await page.waitForSelector('html[data-ready]', { state: 'attached' })\n await page.locator('#open').click()\n await page.getByRole('button', { name: 'Add a screenshot' }).click()\n const canvas = page.locator('#sentry-feedback canvas#background')\n await expect.poll(async () => {\n await repaintCorner(page)\n return canvas.evaluateAll((all: HTMLCanvasElement[]) => (all.length === 1 ? all[0]!.width : 0))\n }).toBeGreaterThan(0)\n\n // The share of the top 40px of the picture that is the page's blue bar.\n const share = await canvas.evaluate((el: HTMLCanvasElement) => {\n const { data } = el.getContext('2d')!.getImageData(0, 0, el.width, 40)\n let blue = 0\n for (let i = 0; i \u003c data.length; i += 4) {\n if (Math.abs(data[i]!) + Math.abs(data[i + 1]! - 102) + Math.abs(data[i + 2]! - 255) \u003c 60) blue += 1\n }\n return blue / (data.length / 4)\n })\n expect(share, 'blue bar share of the top 40px of the screenshot').toBeGreaterThan(0.9)\n})\n```\n\nIt does not fail on an idle machine. It fails when the browser is short of CPU.\n\n## Measured\n\n`mcr.microsoft.com/playwright:v1.62.1-noble` on an x86_64 Linux VM, `docker run --cpus=2`, with 8 busy loops (`while :; do :; done`) running next to the browser, 1 worker, 200 runs each:\n\n| SDK | runs where the picture holds the form |\n|---|---|\n| 11.5.0 as published | 16 of 200 |\n| 11.5.0 with the patch below | 0 of 200 |\n\nIn a larger app with the same setup, no busy loops, 2 CPUs: 1 of 100. With 4 CPUs and no load: 0 of 100. I could not make it happen on a laptop at idle.\n\n## Suggested fix\n\nLet the page draw two frames without the form before asking for the capture, with a timeout so a tab that draws no frames (a background tab) does not hold the screenshot forever:\n\n```diff\n const takeScreenshot = async () => {\n onBeforeScreenshot();\n+ await new Promise\u003cvoid>(resolve => {\n+ let frames = 2;\n+ const next = () => (--frames > 0 ? WINDOW.requestAnimationFrame(next) : resolve());\n+ WINDOW.requestAnimationFrame(next);\n+ setTimeout(resolve, 1000);\n+ });\n const stream = await NAVIGATOR.mediaDevices.getDisplayMedia({\n```\n\nWith this patch the same reproduction gave 0 of 200. On the same load, waiting for one frame instead of two still failed in 3 of 500 runs (the larger app, 2 CPUs with 4 and 8 busy loops); two and three frames gave 0 of 500 each.\n\nHappy to open a PR if that direction is fine.\n","author":{"url":"https://github.com/larcane97","@type":"Person","name":"larcane97"},"datePublished":"2026-10-22T15:39:09Z","url":"https://github.com/getsentry/sentry-javascript/issues/25657"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:42ca705c-cd6a-ef72-9010-c4c2bcd925ad |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9C24:1F98:1954432:2161B79:6B041591 |
| html-safe-nonce | ff11eb04c7d0d7a7be5f242fc1cd02f06a4c07dc8ace0cd467a760b1c4658edf |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QzI0OjFGOTg6MTk1NDQzMjoyMTYxQjc5OjZCMDQxNTkxIiwidmlzaXRvcl9pZCI6IjExOTM4NjIyNTEzNTkyNDU3MTMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | b9a86218f4de3951247ca3037565eac622d784a42b80200c465d98865216a232 |
| hovercard-subject-tag | issue:5982529914 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-javascript/25657/issue_layout |
| twitter:image | https://opengraph.githubassets.com/6473f25c4a9d046c486b1b7e59eb03c3794052dd2d3d02f29b615a54b6211e33/getsentry/sentry-javascript/issues/25657 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/6473f25c4a9d046c486b1b7e59eb03c3794052dd2d3d02f29b615a54b6211e33/getsentry/sentry-javascript/issues/25657 |
| og:image:alt | Is there an existing issue for this? I searched for the symptom and did not find one. Package and version @sentry/browser 11.5.0 (@sentry/feedback 11.5.0), feedbackIntegration({ enableScreenshot: t... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | larcane97 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-javascript git https://github.com/getsentry/sentry-javascript.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 3328572 |
| octolytics-dimension-repository_nwo | getsentry/sentry-javascript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3328572 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-javascript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width