Spherical forums

Sphere Development => Sphere General => Topic started by: Radnen on March 29, 2014, 03:42:16 pm

Title: Be careful of Sphere 1.6 screenshots
Post by: Radnen on March 29, 2014, 03:42:16 pm
I tried making in-game screenshots in Sphere 1.6 a few weeks ago, by hitting the usual button (F11), but something strange happened. I just found out today, by running WinDirStat, that on my SSD, PNG images took up 4.3 GB's of space on my computer. It points me to one large folder in particular, the Sphere screenshots folder.

I check it out and it has over 132,600 files in it weighing in at 3.90GB's of space. It seems every few milliseconds a new image was added, judging by the filenames. (Screenshot attached as proof). I didn't notice this work-load on the computer at the time since the game still ran at 60fps, and since it's an SSD the file writing must have been damn fast (between 10 to 20 ms). My SSD is only 120GB's, and so space can be precious. So, I'm glad to have found this nice chunk of data to happily delete.

So, I guess you don't use the screenshot feature in 1.6, or this could happen to you! This is not the first time that happened to me. It's like the third time. What's strange is that hitting the screenshot button in 1.6 usually does nothing but sometimes this happens... (I sometimes hit F12 when going for F11).
Title: Re: Be careful of Sphere 1.6 screenshots
Post by: N E O on March 29, 2014, 04:33:45 pm
THAT doesn't sound normal o_O

Do you have framerate un-throttled when you attempt this? Do you fat-finger it or accidentally hold it down longer? I don't have 1.6 on this machine so I can't test it out myself right now, but this sounds pretty serious. This is exactly the kind of bug we need to hammer out before declaring 1.6 gold.
Title: Re: Be careful of Sphere 1.6 screenshots
Post by: Flying Jester on March 29, 2014, 05:47:16 pm
I've never seen this before. Good to know!


My SSD is only 120GB's, and so space can be precious.


Imagine what it's like for me on a 32 GB SSD.
Title: Re: Be careful of Sphere 1.6 screenshots
Post by: Radnen on March 29, 2014, 08:32:38 pm

Do you have framerate un-throttled when you attempt this? Do you fat-finger it or accidentally hold it down longer? I don't have 1.6 on this machine so I can't test it out myself right now, but this sounds pretty serious. This is exactly the kind of bug we need to hammer out before declaring 1.6 gold.


I don't know, all I can ay is I accidentally click it sometimes, sometimes it is on purpose (thinking I'm on 1.5 or not). I'm not willing to test that, I hope you understand. :P But I *think* when the framerate is unthrottled it does that, otherwise it doesn't work.
Title: Re: Be careful of Sphere 1.6 screenshots
Post by: Radnen on July 31, 2014, 04:19:46 pm
Ehh, Sphere still does this to me. Who here is also encountering this problem? This is crazy!

FlyingJester: If you read this, do you know enough of Sphere's graphics driver that could cause this? I notice the fps drops to like 20 in fullscreen mode when I play a game. But why would fullscreen affect this when it is a button press - F12 - that creates screenshots and so is therefore tied to a boolean value. I don't understand how this bug even manifests itself.

Edit:
No, it's not full screen. It just does it each and every time I enter the engine. :/
Title: Re: Be careful of Sphere 1.6 screenshots
Post by: Flying Jester on July 31, 2014, 04:56:16 pm
The screenshot mechanism is outside the graphics driver, totally inside the engine. It's using the same call as GrabSurface() uses, and then saving it.

I thought about this issue a while ago, and I noted a place in TurboSphere where I almost made this same bug appear. I based TurboSphere's old SDL_GL_Threaded screenshot code directly on Sphere 1.6's.

This is all based on but a skim of the code, but here are the two hypotheses I have:

* When you hit F12, it sets a flag for screenshots. This flag is checked when FlipScreen is called, and if it is set, we save a screenshot. This flag should be unset afterwards. For some reason, it isn't. This is the bug I saw in TS, but I find this the less likely reason, because...

* Some keyboards and laptops have keys that kind of aren't keys. For instance, some HP laptops have a enable/disable-touchpad button, some keyboards have bizarro media/application keys, which in SDL 1.2 trigger mismatched keydown and keyup events (no keydown, but still a keyup), and have no keysym. SDL2 fixed this, but before I switched I had to work around it.
I've seen the same thing but with different behaviour on old Apple eMac keyboards' eject and F13, F14, and F15 keys (which all trigger two keydowns and no keyups! Bad Apple!).

The screenshot key code is not as similar as you would expect to the other input code in Sphere. It is an ancient thing, added long ago. It's possible that your machine has one of these evil keys, and the normal input code can handle them, but the screenshot key code can't. Every time it polls the key, it's in some screwed up internal state, and claims that F12 has been pressed. This would also explain why I haven't seen this issue personally--my machines don't have keys that behave this precise way.
Title: Re: Be careful of Sphere 1.6 screenshots
Post by: Radnen on July 31, 2014, 05:17:08 pm
Hmm, that does make sense. My new keyboard has a back-light display and I must always have scroll-lock enabled to see it. I wonder if this is the culprit. I'll get back to you on this soon.

Edit: yes, it's Scroll Lock doing it.  :-\

Dang, I don't know what to do, without scroll lock, my keyboard is basically unreadable in dim light.
Title: Re: Be careful of Sphere 1.6 screenshots
Post by: Flying Jester on July 31, 2014, 06:32:53 pm
I could have a look. I know that it would be incredibly easy to just disable screenshots. But I don't like how I've been making new builds of Sphere with more and more stuff disabled. On the other hand, it would be pretty easy to write a screenshot bit in script.

What if you try running it in compatibility mode? That may block events that have a attrib value higher than 255 (big 'may' there).
Title: Re: Be careful of Sphere 1.6 screenshots
Post by: Radnen on July 31, 2014, 07:08:08 pm

I could have a look. I know that it would be incredibly easy to just disable screenshots. But I don't like how I've been making new builds of Sphere with more and more stuff disabled. On the other hand, it would be pretty easy to write a screenshot bit in script.

What if you try running it in compatibility mode? That may block events that have a attrib value higher than 255 (big 'may' there).


I myself use my own screenshot code rather than Sphere's. The neat thing is I can add a watermark to them to create "branded" or "official" game screenshots, lol. All you do is wrap the render script and the FlipScreen functions JS-side with ones that saves the output before rendering.

I'll try the compatibility mode and get back to you.

Edit: nope, no compatibility mode works. I don't know what Sphere uses for keys, it's not SDL (I think). This happens on any graphics driver, so the event for handling screenshots is not in a graphics driver, but inside the engine. If it uses Windows API keys, it should work, right? http://msdn.microsoft.com/en-us/library/ms646293%28VS.85%29.aspx
Title: Re: Be careful of Sphere 1.6 screenshots
Post by: Flying Jester on July 31, 2014, 07:25:39 pm
I believe Sphere does use the native Windows API when in Windows.
The issue is that there are some events that are masked as keyevents but aren't properly keyup or keydown. If you just try to catch keydown events naively, you will end up with cases where your code acts like there are events pending, but it can't pop any new events (or it pops events with 'full' masks). It mostly seems to happen with non-standard state keys (exactly like what your keyboard has). Similarly, TurboSphere used to do similar things on my old HP laptop with the touchpad-enable/disable button if I had the touchpad disabled, probably for the same reasons.