Snapshot/Screenshot very slow

MrOut

Member
Hello,

I try to implement a snapshot/screenshot button in my game but with the screen_save(fileName) function, this is very slow. I got a huge drop in FPS. Same with the 'Snapshot' option into an object.
I notice also that screen_save put in the image file my Steam overlay (FPS counter and notifications for examples).
I tried other games in my list made with Gamemaker (Hotline Miami and Gunpoint) and there is not this problem with Steam overlay, or FPS drop.

I also try with surface_save(surfaceID, fileName) but I got the same result. This is too slow with a massive drop in FPS.

If anyone as an idea, I'm all ears.

Thanks in advance.
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
There shouldn't be ay drop in FPS with these functions as long as it's only called once... Make sure you have it in a DOWN event and not a PRESSED event, so it's not taking screenshots every single step of the game that the key s pressed. As for the steam overlay, I haven't found this but then I haven't tested it either! Certainly it's not something I've had reports of for my own games on steam... I suspect it might depend on WHEN you call the save code so, if you could provide that information and the actual code you are using then that would be great.
 

MrOut

Member
Thanks for your response.

I call my code from a step event object dedicated to all Steam functionality (Achievements, Screenshots,etc...).

So basicaly I have a obj_steam and in the step event i got this code:

if (steam_is_screenshot_requested()){

//SCREENSHOT
screen_save("screenshot.png");

//SEND SCREENSHOT TO STEAM
steam_send_screenshot("screenshot.png", window_get_width(), window_get_height());
}

I will try with a down event ( I guess you mean released?).

I also notice that when I use screen_save_part() and take only 500x500 pixels it's way faster.
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Okay, iirc, there is a bug with the function that means if you don't explicitly use "== true" then it runs all the time!!!! SO, make sure the code actually says:

Code:
if steam_is_screenshot_requested() == true
Also, I usually call the screenshot functions in the Draw GUI End event. Here's an example of the code I use in all my Steam games if it's any help to you...:

Code:
var _scr = false;
if steam_is_screenshot_requested() == true
    {
    log("Steam Screenshot Request"); // wrapper script for show_debug_message
    _scr = true;
    }
if keyboard_check_pressed(vk_printscreen)
    {
    log("PrintScreen Screenshot Request");
    _scr = true;
    }
if keyboard_check_direct(vk_printscreen)
    {
    log("PrintScreen Direct Screenshot Request");
    _scr = true;
    }
if _scr
{
screen_save_part(file, 0, 0, window_get_width(), window_get_height());
if steam_initialised()
        {
        steam_send_screenshot(file, window_get_width(), window_get_height());
        }
}
EDIT: Yup, there is a bug on Mantis about this: https://bugs.yoyogames.com/view.php?id=31230
 

MrOut

Member
Thanks a lot.

I put your code in a Draw GUI End event and it's way faster. But there is still some microseconds after the screenshot is taken where my game is freezing.
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
But there is still some microseconds after the screenshot is taken where my game is freezing.
I'm not sure there is much that you can do about this, tbh... GMS is not a multi-threaded app, and so saving an image file (especially if the image is fairly large) will require a tiny pause in the running of the game.
 

MrOut

Member
This is probably nothing, but there is always a significent size differences between the screenshot taken by Gamemaker and the one send to the Steam folder.
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
This is probably nothing, but there is always a significent size differences between the screenshot taken by Gamemaker and the one send to the Steam folder.
Interesting... I've never actually checked this, but I'd suspect it's something that the Steam API does to compress the image for uploading. Certainly, GMS does no such thing...
 

MrOut

Member
With your code, but this was the case with mine too, if I took only a small part of the screen there is no delay.
So this as definitely something to do with big resolution (in my case at least).

The screenshots I took of Hotline Miami have the same size as my screen (2560*1440) so I guess they use a trick somewhere.
 

MrOut

Member
I made some changes to my textures pages, switching from 2048*2048 to 8192*8192. I have a massive gain of time on my screenshot delay now. This is still not perfect, but I maybe have a lead.

I let you know if I make any progress.
 
Top