altv-issues icon indicating copy to clipboard operation
altv-issues copied to clipboard

alt.takeScreenshot and alt.takeScreenshotGameOnly are capturing overlay

Open Chronicle1337 opened this issue 2 years ago • 6 comments

Description of the problem

alt.takeScreenshot and alt.takeScreenshotGameOnly are capturing steam, discord, overwolf and probably more/all overlays when they should only capture the game and no overlays. Was trying to make a mugshot function for model, while my server lagged the screenshot was delayed and captured my discord overlay so i found the bug.

Reproduction steps

Make a chat/keybind or automatic timer for screenshot with a delay (for opening your overlay), open discord/steam overlay and wait until the screenshot was taken, close steam/discord overlay and the overlay is visible on the screenshot. Tried to reproduce it the best way possible with another user and a fresh windows 10 installation, results were the same, tested with Fullscreen, Windowed and Borderless Fullscreen. Tested on Windows 10 and Windows 11. Tested with alt.takeScreenshotGameOnly() and alt.takeScreenshot(). Happened with both OS and both commands, also alt.takeScreenshotGameOnly() captures most of the time overlays. Some screenshots are without ingame overlays but most of the time alt.takeScreenshotGameOnly() also captures ingame overlays.

Expected behaviour

Overlays shouldn't normally not be captured.

Additional context

No response

Operating system

Windows 11 22H2, Windows 10 22H2

Version

Release 14.20

Reproduction tested

  • [X] I confirm that I have made sure that this issue is also present on the newest dev version

Chronicle1337 avatar May 29 '23 13:05 Chronicle1337

I think dublicate of https://github.com/altmp/altv-issues/issues/1629

litolax avatar May 29 '23 14:05 litolax

I think dublicate of #1629

I'm not sure if the problem causing this is the same, but in the one you mentioned it's about the webviews in the game while my issue is about overlays like steam or discord.

Chronicle1337 avatar May 29 '23 19:05 Chronicle1337

This seems like a issue related to FPS. Had the same when i worked on a project some months ago but hadn't the time to investigate further. When you uncap your FPS so your netgraph 1 shows 187/188 FPS all the time your overlays you had open by the time you took your screenshots are shown, the same issue with (https://github.com/altmp/altv-issues/issues/1629) alt.takeScreenshotGameOnly your webviews are shown nearly every screenshot. When you cap your FPS to 120 for example 99% of the time no overlays and GameOnly also shows no webviews.

omuc avatar Jun 07 '23 07:06 omuc

Confirmed on 15.0-dev360

xxshady avatar Jul 15 '23 15:07 xxshady

Reproduction code

  1. Make sure you have given "Screen Capture" permission
  2. Serverside: (saves test_screenshot.png in root server folder)

alt.onClient('screenshot', async (player, screenshot) => {
    alt.log('screenshot')
    const fs = await import('fs')
    fs.writeFileSync(
        `test_screenshot.png`,
        screenshot,
        'base64',
    );
})
  1. Clientside
alt.setInterval(async () => {
    const screenshot = await alt.takeScreenshotGameOnly()
    // in context of this repro it doesnt matter if screenshot is not sent in its full size
    alt.emitServer('screenshot', screenshot)
}, 1000)

xxshady avatar Jul 15 '23 15:07 xxshady

The problem is still there. Recently, I started working on a server again, and the screenshot function keeps capturing my Discord overlay, showing which people I'm currently chatting with.

It's not a big problem per se, but when I only had one screen, I used the Steam browser for browsing while playing. It would be unfortunate if the Steam browser with private things like WhatsApp, etc., were then captured.

And there will certainly be plenty of people who still have one screen.

omuc avatar Feb 24 '24 10:02 omuc