Skip to content
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

Screenshot crash #73

Closed
johndh opened this issue Mar 14, 2016 · 8 comments
Closed

Screenshot crash #73

johndh opened this issue Mar 14, 2016 · 8 comments

Comments

@johndh
Copy link

johndh commented Mar 14, 2016

When attempting to take a screenshot during play or in the main menu, the game immediately crashes without saving the image. I'm on 64-bit Linux Mint and the print screen command on my laptop is fn+insert. This only happens when playing in fullscreen; it does not happen in windowed mode. I can take screenshots in other fullscreen games with no issues.

*** Error in `./stratagus': double free or corruption (!prev): 0x0000000014857020 ***
Aborted

I tested out some other keys to see if they would cause a crash. The volume LEDs and the brightness commands (fn+f9 and fn+f10) do not work but don't cause a crash. The SysRq key combination (fn+delete) causes a crash with similar output to the screenshot.

*** Error in `./stratagus': double free or corruption (!prev): 0x00000000147cc360 ***
Aborted
@Andrettin
Copy link
Owner

Thanks reporting this issue; unfortunately I am not able to reproduce it.

SysReq also takes a screenshot, so the issue is likely with the Screenshot() function itself (or the SaveScreenshotPNG() function it calls).

Does this crash happen both when you are playing with OpenGL rendering enabled, and when it is disabled?

@johndh
Copy link
Author

johndh commented Mar 14, 2016

The crash only happens with OpenGL rendering enabled. As it turns out, it was taking screenshots, but I was expecting to find them in my Pictures folder where screenshots normally go. I hadn't thought to look in ~/Wyrmgus. The ones that resulted in crashes turned out rather oddly, while the ones with OpenGL disabled turned out fine.

Odd result:
screen01

@Andrettin
Copy link
Owner

Thanks, that's helpful :)

So the issue is likely in the following piece of code in SaveScreenshotPNG() (in \video\png.cpp):

#if defined(USE_OPENGL) || defined(USE_GLES)
    if (UseOpenGL) {
        std::vector<unsigned char> pixels;
        pixels.resize(Video.Width * Video.Height * 3);
#ifdef USE_OPENGL
        glReadBuffer(GL_FRONT);
#endif
        glReadPixels(0, 0, Video.Width, Video.Height, GL_RGB, GL_UNSIGNED_BYTE, &pixels[0]);
        for (int i = 0; i < Video.Height; ++i) {
            png_write_row(png_ptr, &pixels[(Video.Height - 1 - i) * Video.Width * 3]);
        }
    } else
#endif

@Andrettin
Copy link
Owner

timfel has made an update to fix this issue, which I've implemented into Wyrmgus here:
f271eb5

Does it fix the problem for you?

@johndh
Copy link
Author

johndh commented Mar 15, 2016

The game no longer crashes upon taking a screenshot most of the time, but the screenshot is still gray and distorted as before (or a corrupted file), and the game freezes upon trying to exit if I previously took a screenshot during that session. It still sometimes causes the game to freeze, which seems to occur more when I've switched from windowed to fullscreen. I also still managed to crash it once by just taking a screenshot in the opening menu (output below). As before, everything is fine with OpenGL disabled.

*** Error in `./stratagus': double free or corruption (out): 0x0000000015b59460 ***
./launch: line 1: 31990 Aborted                 ./stratagus -d ~/Wyrmsun/ -u ~/Wyrmsun/

In this case ./launch refers to ./stratagus -d ~/Wyrmsun/ -u ~/Wyrmsun/, the script I use to launch the game.

@Andrettin
Copy link
Owner

Unfortunate that it didn't fix the problem, but at least there was some improvement. There was a further update from upstream on this issue which I've implemented into Wyrmgus, maybe it will help:
a645c96

@johndh
Copy link
Author

johndh commented Mar 17, 2016

That doesn't seem to have made any difference.

@Andrettin
Copy link
Owner

This should be fixed now with the following commit:
9514a22

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants