Nifflas' Support Forum

Released Games => Knytt Stories => Topic started by: Lit Knob on September 26, 2021, 15:09:53

Title: How to fix performance issues?
Post by: Lit Knob on September 26, 2021, 15:09:53
Performance in Knytt Stories is quite an obscure topic no one ever talks about (unless I'm just bad at searching) so I just didn't know where to ask, anyway: in current versions and mods (plus and EX) Windows DWM's forced V-Sync really hurts performance like in the base game due to it being borderless and running at 50 fps (apparently DWM is not a fan of that) and it currently lags with 32-ish fps. I know some of you, if not all of you, managed to get the game to run properly at 50, like Don Doli for example but I'm still clueless.
I tried changing the refresh rate to 50 Hz (my monitor's max refresh rate is 75 Hz and neither that nor 60 work) but there's still some lag.
My question is: has this issue already been widely addressed and fixed?
If so, what is the current solution?
If there indeed is one, I think it should be mentioned in the plus and EX mods to make the game newcomer-friendly
Title: Re: How to fix performance issues?
Post by: ixMarcel on September 27, 2021, 17:02:53
I had that issue with my previous Radeon graphics card, but with my current RTX 3070 KS runs butter smooth.

You game will probably run full-FPS if you enter fullscreen mode, but that stretches out the graphics. You can try to open your GPU control panel and change KS profile to something else than default (Radeon has something like Gaming Mode I think).
Title: Re: How to fix performance issues?
Post by: Lit Knob on September 27, 2021, 20:28:02
My pc specs are:
Ryzen 7 2700
Gtx 1070
16 GB RAM
Nvidia driver 471
Windows 10 1909

I play Knytt Stories+ 1.3.6 with Zoom and Hide Desktop on. I confirm that fullscreen works (but as you mentioned it has no integer scaling so it's not a solution)

My card is Nvidia like yours though, so the cause must be something else.
I also tried changing Nvidia control panel settings, like disabling/enabling V-Sync but nothing changed.

Maybe your Windows and Nvidia driver versions are the answer.
Also your refresh rate
Title: Re: How to fix performance issues?
Post by: egomassive on September 30, 2021, 04:07:46
GrayFace made a program that enhances the output of older Nifflas games. I haven't used it myself and I don't think KS+ is compatible, but original KS and KS Ex should work.
https://nifflas.lp1.nl/index.php?topic=7193 (https://nifflas.lp1.nl/index.php?topic=7193)

I was aghast after upgrading to Win8/10, but now I've just grown numb to the poor frame rate.
Title: Re: How to fix performance issues?
Post by: Lit Knob on September 30, 2021, 18:31:02
GrayFace made a program that enhances the output of older Nifflas games. I haven't used it myself and I don't think KS+ is compatible, but original KS and KS Ex should work.
https://nifflas.lp1.nl/index.php?topic=7193 (https://nifflas.lp1.nl/index.php?topic=7193)

I was aghast after upgrading to Win8/10, but now I've just grown numb to the poor frame rate.
I tried Scaler on Plus, EX and the base game but it just acts as your zoom feature sadly, it does not fix the lag.

For now, the only thing I tried that gets rid of it is going fullscreen (alt+enter) on your mod as stated by IxMarcel (fullscreen still lags in EX and the base game, for some reason) but of course it's not a proper solution.

I also tested YKnytt (a Knytt Stories made in Godot that runs at 60 fps) but it suffers from several issues such as atrocious input lag, and bad sound effects and scaling. It has great potential but In its current state I definitely don't consider it a valid alternative to Plus and EX. You guys still have the crown.

Any other suggestions/possible solutions?

I still don't understand why Don Doli and IxMarcel are not affected. It would be nice to finally uncover the truth.

More useful info: Don Doli is an 8.1 user. He has a 60hz refresh rate and a 1070 ti (so Nvidia) and also stated the game (Plus) just worked, out of the box and he didn't need to disable DWM nor anything...

The mistery deepens
Title: Re: How to fix performance issues?
Post by: Lit Knob on October 03, 2021, 18:06:12
I found a possible solution, but it's a bit annoying and introduces screen tearing so not ideal but still:

I used DWM Killer by PolisGod after running KS+. It completely disables DWM, not just for the Knytt window (so also disables taskbar and desktop among other things). It's a bit extreme as a solution but I personally despise tearing, so it's not worth it for my tastes.
You can give it a try if you don't mind screen tearing, but only if you plan on playing the game and nothing else at that specific moment (not suited for multitasking).

I guess I'll get used to the 30-ish fps like egomassive for now.

If anyone finds a proper definitive fix that doesn't involve upgrading hardware, please let me know.
Thanks
Title: Re: How to fix performance issues?
Post by: egomassive on October 04, 2021, 00:20:41
I wouldn't think screen-tear would be a big issue with KS since the screens don't scroll or move around, only the objects with-in them move. Unless you can set your monitor to 50Hz while jail-breaking from v-sync, I don't think it's possible to run at 50 fps without tearing.

I tinkered with the KS+ source to see if I could get it to run in fullscreen mode with integer scaling. The base engine does the dumbest thing. It boxes the game window into the smallest standard monitor resolution it can fit into, and then sets the monitor to that resolution. The only surefire way to work around this behavior is to set the game's window size to match the monitor you're using. This means I'd have to compile a different version of KS+ for every typical monitor resolution in use today. I won't do that. It's too janky and too complicated for end users.
Title: Re: How to fix performance issues?
Post by: Lit Knob on October 04, 2021, 02:37:11
I wouldn't think screen-tear would be a big issue with KS since the screens don't scroll or move around, only the objects with-in them move. Unless you can set your monitor to 50Hz while jail-breaking from v-sync, I don't think it's possible to run at 50 fps without tearing.

I tinkered with the KS+ source to see if I could get it to run in fullscreen mode with integer scaling. The base engine does the dumbest thing. It boxes the game window into the smallest standard monitor resolution it can fit into, and then sets the monitor to that resolution. The only surefire way to work around this behavior is to set the game's window size to match the monitor you're using. This means I'd have to compile a different version of KS+ for every typical monitor resolution in use today. I won't do that. It's too janky and too complicated for end users.
Ok, I tried a 50hz + DWM killer combination and there's still tearing for some reason. By the way, I know the background has no tearing but as you stated, moving things are still affected, so for example Juni, enemy bullets and opening the map all get tearing and I notice it.
Anyway

I would love that integer-scaled exclusive fullscreen mode.
Can you try to just implement it for 1080? (The most common resolution right now).
I know it can feel "unfair" to 4K and 4:3 users for instance, but maybe it's a good starting point, I don't really know
Title: Re: How to fix performance issues?
Post by: egomassive on October 04, 2021, 23:13:38
I'll do it as a test. I have an onboard chipset so nothing will ever make my frame rate better. The program itself has always been set to no v-sync, so I'll give you the option to toggle that. If you can v-sync at 50hz, that may get the result you're looking for.

KS+ 1.3.7 is almost ready to launch. I'll make the native 1080 version when it's ready.
Title: Re: How to fix performance issues?
Post by: Lit Knob on October 05, 2021, 04:57:22
YES. That's exactly what I wanted. Thanks egomassive.
I would give you a star now, if only I knew how to do that. I see no up arrows anywhere
Title: Re: How to fix performance issues?
Post by: LPChip on October 05, 2021, 17:31:14
The up arrow is something from the past. There is now a link  at the left that says "Give a star". Click that for it to work.

Also, if you have 2 graphics cards, for example a dedicated graphics card AND an integrated GPU from the CPU or motherboard, windows may wrongly do hardware accelleration over the integrated GPU with poor performance.
Title: Re: How to fix performance issues?
Post by: Lit Knob on October 05, 2021, 21:02:05
Ok, I didn't know that. Thanks.
I guess mobile users can't give them though, because there's no "Give a star" even in desktop mode. I had to give them on my PC.

Oh I forgot to mention it in my specs list: I have 2 identical 1070 cards but there's no SLI bridge so only one is used (they only work in tandem when I use a really demanding software called Blender. Using it was the main focus of my workstation), so I don't know if what you said applies to this situation.
Title: Re: How to fix performance issues?
Post by: Purple Ink on October 10, 2021, 03:33:06
Am I just lucky? I don't have any FPS related issues with Knytt Stories.
Title: Re: How to fix performance issues?
Post by: Lit Knob on October 10, 2021, 07:45:39
If you are a Windows 10 or 8.1 user then yes. IxMarcel and Don Doli are also unaffected and I still have no idea why.

My original goal in this thread, was solving this "murder mistery" about pc specs and lag, and finally find the cause, but then egomassive started working on KS+ 1.3.7 and I stopped investigating cause I didn't feel the need anymore.

My current analysis of the "crime scene" is as follows:

Me, Don Doli and IxMarcel all have an Nvidia card, and Don Doli's is the Ti version of my card, so GPU is not involved.
Me and Don Doli both have a 60hz refresh rate so it can't be that.
We all play KS+ so game version is not the problem.
I have an AMD CPU while Don Doli's is Intel, but I tried the game on my second pc that has an Intel CPU and it lags there, so CPU brand doesn't matter.
Me and Don Doli both have 16 GB but I mean... It's a 2007 pixel art game so... why even bother about RAM.
The only thing that really sets me apart hardware-wise is the fact I have 2 identical Nvidia cards but in my second computer there's a single AMD card, so it can't be that.
I pretty much think and hope at this point that hardware in general is not the cause.

Software-wise I only know my OS is Windows 10 1909 and my Nvidia driver is 471.11, while Don Doli is a Windows 8.1 user.

As Don Doli stated, KS+ just worked out of the box, so I have to consider trying the game on my third computer (I don't have more so that's the last thing I can do on my end).

You can share your pc specs/Windows and GPU driver version/other things if you think it can narrow down the "suspect pool".
Title: Re: How to fix performance issues?
Post by: Lit Knob on October 11, 2021, 03:19:56
I can confirm it lags on all my 3 computers...

Ouch

This issue is not so rare as it seems then, it's actually the opposite.

My third pc has an old AMD A8 and a Gt 1030. Nvidia driver version is the same as my main pc, while Windows 10 version is 20H2, so updating it will not fix the issue.

I will just wait for the new KS+ version for now. If it really fixes everything forever, there's no point in finding the cause of the lag.
Title: Re: How to fix performance issues?
Post by: Purple Ink on October 12, 2021, 04:32:28
I had a thought: could it be because Ks isn't installed on the same drive as windows?
Title: Re: How to fix performance issues?
Post by: Lit Knob on October 12, 2021, 06:41:43
My other 2 computers both have a single drive, so I guess that's not the case, sadly. I will try and copy-paste KS+ in the C drive in my main pc just cause, but as I just said, it shouldn't change anything.
Title: Re: How to fix performance issues?
Post by: egomassive on October 12, 2021, 10:16:58
KS+ 1.3.7 is out with a v-sync switch and a native 1080 version.
https://nifflas.lp1.nl/index.php?topic=4175.msg75639#msg75639 (https://nifflas.lp1.nl/index.php?topic=4175.msg75639#msg75639)
Title: Re: How to fix performance issues?
Post by: Lit Knob on October 13, 2021, 03:53:40
Bad (also weird) news: I tested the new version and noticed 2 things:

It seems just setting refresh rate to 50hz is enough to stop the lag, because both 1080 version and ctrl X run smooth with it (they both lag as usual on 60hz) so I guess the update just got better performance in general when set to 50hz in comparison to previous ones? The thing is, there is random occasional lag now. Sometimes it's just smooth for several minutes (up to 12 in current tests) then it suddenly starts lagging, then goes back to smooth after another couple minutes. I don't know what's causing this really inconsistent lag when set to 50hz.

The second thing, that really doesn't make sense to me is the fact that when I test the old stretched fullscreen it has this same behavior even with refresh rate set to 60hz. So I guess there shouldn't even be the need to switch to 50hz to make it work in the 1080 version. I don't really know, just an observation. No idea how to get rid of the random lag though.

A third thing I noticed: I used DWM killer to see if it fixed the random 50hz lag, and while it seems to fix it, the new V-Sync either gets disabled too by DWM killer, or I just don't know what actually happens, because I get tearing (but just with DWM killer. There's no tearing when playing the usual way). I’m not sure what's the case here but I don't like DWM killer as a solution anyway, so just another observation.

I tried DWM killer again while also forcing Nvidia’s pretty good V-Sync. I’m not entirely sure it worked, but I didn't notice any tearing. The idea of disabling like half of the OS just to avoid some random lag still bothers me though.

Any idea what the problem might be?

What about unaffected users like Purple Ink and IxMarcel? Does the game just run the same as before?

Another thing I noticed: in my second computer the game constantly lags even with 50hz, so I'm starting to believe this game needs a "beefy" computer, for some reason (but 2 percent CPU and 15 percent GPU usage shown in Task Manager in my main pc suggests the opposite). Maybe my second computer is just really messed up software-wise. I'll try the game on my third one for comparison.
Title: Re: How to fix performance issues?
Post by: egomassive on October 13, 2021, 07:39:25
My first thought is the periodic lag may be due to another windows process, one that runs periodically in the background. You could try increasing the priority of KS if that's still possible in Win10. Also, check your power settings. Something could be dropping into a power conservation mode.
Title: Re: How to fix performance issues?
Post by: Lit Knob on October 13, 2021, 18:22:48
I set priority to high, nothing changed. My current power plan is High performance and things like screensaver/sleep/suspend are set to never, I don't know if that's what you meant by power settings.

I checked task manager but I didn't see any "suspicious" processes. When the game is running, CPU usage is 2 percent, and GPU usage is 15, and they stay like that even when it's lagging.

Is it possible the 1080 fullscreen is actually still borderless like ctrl X, therefore affected by DWM's V-Sync? That would explain why they have the exact same performance, while also rendering the new KS+ V-Sync useless. But if that's the case, why would DWM periodically hurt performance instead of constantly doing it, when set to 50hz?

This whole DWM issue raises this question: what is causing DWM's poor V-Sync to "work properly" in unaffected users' systems? Is that even what's actually happening to them? What gives them the "privilege"?

Oh, I couldn't try the new version in the third pc. Turns out its monitor can't be set to 50hz, just 60 or 75. When set to those two values, it lags as usual.
Title: Re: How to fix performance issues?
Post by: Lit Knob on October 14, 2021, 17:12:56
Ok, I think I know what's going on:

When I started this thread, the original problem was constant lag caused by DWM's V-Sync. The fact the 1080 fullscreen still exhibits this behavior lead me to think it's affected by DWM. So I tried it with V-Sync disabled and as I expected, there wasn't any tearing at all. That means some other V-Sync is taking care of it and overriding yours (an even weirder thing is the fact when I disable DWM's V-Sync with DWM killer, it still doesn't let yours to work). Then I tried the start and task manager trick, that always minimizes games with exclusive fullscreen. As I expected, when pressing win key and opening task manager, KS+ doesn't hide in the taskbar. Even more obvious: when I disable DWM with DWM killer, the game runs smooth on 60hz.

All these things together seem to suggest the 1080 fullscreen is still a borderless window like ctrl X, for some reason.

Can you confirm this or disprove it?
Please let me know.
Title: Re: How to fix performance issues?
Post by: Lit Knob on October 16, 2021, 07:54:39
Other things I found (and Fusion games I tested for comparison): I tried the game "I wanna be the guy" (made in Fusion 2 and capped at 50 fps like KS. Also is windowed-only) and DWM doesn't hurt its performance. It perfectly runs at 50 fps with system refresh rate set to 60hz.

I recently played and finished Knytt Underground and it ran at constant 56 fps (and it's correct exclusive fullscreen. Is the weird frame rate number intentional though? I thought that game was capped at 60). I think that's thanks to Mathias' Chowdren though, so I guess it doesn't count as a proper comparison.

Also I probably should have mentioned this earlier but: I have really huge games like Forza and Ace Combat among other things, and Knytt Stories is literally the only thing that lags, in my whole computer...
Yeah, that's unfortunate.

So I guess it's safe to say at this point, whatever the difference between my computer and unaffected users' is, it only affects this game, for some obscure reason.
Title: Re: How to fix performance issues?
Post by: egomassive on October 16, 2021, 10:16:09
Is it all KS versions or just KS+ at this point? KS+ does something weird to get the integer scaling and the fullscreen mode in the same package. The game window is actually a sub-application launched from the main window which presents itself as the black border seen in cinema mode. I don't know how this could affect refresh rates, but it does set it apart from most other games.

Here's another facet. The v-sync option added to version 1.3.7 is applied to the program by the main window. I've no idea if this affects the child window. Although, I have received a positive report from another user on the v-sync option's effectiveness.
Title: Re: How to fix performance issues?
Post by: Lit Knob on October 16, 2021, 22:21:30
There you go. A benchmark of the Tutorial's first 10 seconds with refresh rate set to 60hz (I didn't test 50hz but I will if you are interested):

KS 1.2.1:

Windowed – 48/50, at least 8 frames get “corrupted” (there are very minor differences or none at all, for example a single raindrop appears/moves down while everything else is frozen, or the whole frame just gets repeated. The corrupted frames clearly take the place of the proper missing ones, because raindrops are way more distant between the corrupted frame and the next one). This corruption gives the “illusion” it's running at 37/40. Also I didn't notice before but “I wanna be the guy” has this exact same issue… my bad.

Fullscreen – 47/49, same corruption but way worse (several raindrops, sometimes even Juni only move in a frame). The repeating pattern is very inconsistent. Illusion: random 37/39

KS Ex:

Cinema mode – 50, the corruption is only comprised of perfectly repeated frames, no small differences. Illusion: stuttery 40. Repeating pattern: 4+1 (4 different frames + a copy of the fourth).

Fullscreen – 50, same heavy corruption and inconsistent pattern of the base game's fullscreen. Illusion: random 37/43

KS+ 1.3.6:

Cinema mode – 50, sometimes with an inconsistent pattern. Frames just get repeated like the Ex mod, no differences. Illusion: stuttery 40. Repeating pattern (not counting occasional inconsistencies): 4+1

Fullscreen – 50, no corruption (weird, huh?). Repeating pattern: none, every frame is different (well, finally…). The thing is, if we count the 60hz refresh rate as 10 extra frames, the resulting “repeating pattern” is not that consistent unfortunately, it's not 5+1. It's a random sequence of 5+1, 4+1 and 6+1, so even though every frame can be seen for once, it still doesn't look “exactly smooth” with this fullscreen mode (But maybe the issue is fixed on 50hz).

KS+ 1.3.7 1080:

Cinema mode – 36/47… What? I don't really know what happened but it was lagging. Corruption was only repeating, but I guess if it wasn't lagging, it's safe to say it would have had the behavior of the previous version.

Fullscreen (the 1080 one) – 41/50, almost the same as above (it was still lagging). No idea why. I don't know if this new version always lags like that at 60hz. Kinda ironic.

I also tried the original Knytt (the tail one) and results were: fullscreen – 47/48, windowed – 47/49, with the same corruption behavior as KS 1.2.1.

I don't know if it really changed anything, but I updated the Nvidia driver to latest, 3 days ago.

Regarding V-Sync, maybe Pfrangip didn't check for tearing before enabling it and assumed it worked, I don't know. If he gets the game to run smooth on 60hz, maybe he could help us find out what's wrong with all my 3 computers and this game. In the other hand, if he doesn't get periodic lag on 50hz he could still help us.
Title: Re: How to fix performance issues?
Post by: Lit Knob on October 20, 2021, 16:04:26
Any news? If you want me to also test 50hz let me know
Title: Re: How to fix performance issues?
Post by: egomassive on October 22, 2021, 15:09:21
Sorry, thanks for all the info. It's interesting, but it doesn't bring me any closer to understanding why one game runs well and another doesn't. It is disappointing that the 1080 version didn't break out of window's frame-rate jail for you. I've done everything I can think of to give users a better chance at a good frame-rate. I don't know what further tests could reveal, but I doubt they'll reveal anything that points us to a solution.
Title: Re: How to fix performance issues?
Post by: Lit Knob on October 22, 2021, 17:20:18
Ok. The most interesting things to me are the fact all my computers are affected, hardware seems not to be involved and the previous KS+ fullscreen is the only one that runs almost perfect for some reason. Maybe there's something different in the source code? If that one fullscreen can be made integer-scaled, I think that would bring us closer.

I'd really like answers to the following:
Is it possible to just raise the frame rate cap to 60?
Can the Ultimate Fullscreen extension by Ultimatewalrus be implemented and would it fix the issue in the first place?
Can the game just be recompiled to C++ with Mathias' Chowdren?
Title: Re: How to fix performance issues?
Post by: kilicool64 on October 24, 2021, 14:49:55
To my understanding, porting games to Chowdren is very difficult. It may also not support all of Knytt Stories' plugins.
Title: Re: How to fix performance issues?
Post by: egomassive on October 24, 2021, 17:46:56
Does then normal 1.3.7 not run as well as 1.3.6? You only listed 1.3.7-1080 in your bench tests. I was under the impression it was the very fact that I changed the native resolution of the game to match your monitor that trapped you into the bad frame rate.

You can't raise the frame rate of the game without reprogramming everything. The frame rate is used for timing on most aspects of the game. I don't know anything about Ultimate Fullscreen or Chowdren, and I'd rather keep it that way. I'm not actively developing KS+ anymore, and I can't stand working with MMF2. I'm mainly just doing maintenance. Major overhauls aren't going to come from me. The KS+ source is available up to 1.3.6, and there are several remakes in the works. Also Win11 is on its way, there's no telling what surprises it will hold for old programs.
Title: Re: How to fix performance issues?
Post by: Lit Knob on October 24, 2021, 20:31:07
To my understanding, porting games to Chowdren is very difficult. It may also not support all of Knytt Stories' plugins.
Oh ok, that's unfortunate.

Does then normal 1.3.7 not run as well as 1.3.6? You only listed 1.3.7-1080 in your bench tests. I was under the impression it was the very fact that I changed the native resolution of the game to match your monitor that trapped you into the bad frame rate.

You can't raise the frame rate of the game without reprogramming everything. The frame rate is used for timing on most aspects of the game. I don't know anything about Ultimate Fullscreen or Chowdren, and I'd rather keep it that way. I'm not actively developing KS+ anymore, and I can't stand working with MMF2. I'm mainly just doing maintenance. Major overhauls aren't going to come from me. The KS+ source is available up to 1.3.6, and there are several remakes in the works. Also Win11 is on its way, there's no telling what surprises it will hold for old programs.
I just tried 1.3.7. There was some lag but not as much as the 1080 version. The fullscreen is not smooth like the 1.3.6 one. From my experience, 1.3.7 runs way better when set to 50hz in comparison to previous versions, for some reason.
Any idea why the 1.3.6 fullscreen runs smooth?

Wait, what are the other remakes besides YKnytt?

I will try Win 11 on one of my computers at some point to see if it changes anything and if it's worth it in general. I don't know when though.
Title: Re: How to fix performance issues?
Post by: egomassive on October 24, 2021, 22:55:21
There are only minor differences between 1.3.6 and 1.3.7. I added some logic to improve the menu that only runs on the first cycle when you load a game, the search bar in the level selector behaves differently, and the screen edge glows green with the detector. This last one could cause an extremely small increase in processor need, but I doubt it would change frame rates. Now that I'm thinking about it, I can make that lighter. It paints the image now. I'd be faster if I added a pre-rendered green version. The v-sync switch does nothing unless you select it, so if you leave it alone it shouldn't bother anything.

yknytt is the only recent attempt I've heard of, but there have been other starts. KSDS is complete, but it's Nintendo DS homebrew. Not sure how it performs in emulation.
Title: Re: How to fix performance issues?
Post by: Lit Knob on October 25, 2021, 01:53:04
Ok. The fact one of those things could affect fullscreen performance is really weird to me.

I read the KSDS manual. Community levels require music and ambience ogg files to be converted to mp3 and raw respectively, with a much lower sampling frequency. Being an "audio guy", I really don't think I could bear the difference in sound quality (and converting sound files in 100+ levels is not something I personally would do anyway).
It has no map. I almost always force your nice map in large non-linear levels.
Also it probably doesn't support levels made in your mod.

I think a finished YKnytt with all issues fixed would be a good "solution", but the latest update is dated feb 2020 and it doesn't seem to be active.

I had a thought: if you manage to fix the 1.3.7 fullscreen regression, maybe the 1080 fullscreen would also stop lagging?
Title: Re: How to fix performance issues?
Post by: Lit Knob on October 25, 2021, 20:07:27
I just tried the 1.3.7 fullscreen again and it was almost running smooth like the previous one (lag is occasional, I guess?). The 1080 version still lags though.
Title: Re: How to fix performance issues?
Post by: egomassive on October 25, 2021, 20:55:32
That's good. I mean it's not good, but I'm glad I didn't break the mysterious set-up that allows KS+ to run better sometimes.