fheroes2
fheroes2 copied to clipboard
Make lags more smoother
Preliminary checks
- [X] I've checked that there aren't other open issues on the same topic.
Describe the problem requiring a solution
Currently game menu have few places with hangs for some seconds:
- [ ] if you put a lot of maps in maps directory, then click "standard game" from the "new game" menu
- [ ] if you click "Language" in "options" menu
Describe the possible solution
I suggest showing the new window, on top of all windows, with an ICN::HOURGLAS
animated icon without any progress bar. This will be more common to any user expirience.
Additional info
No response
What about just changing game cursor to sundial in such cases? It's a common feature for PC OSes, when cursor changes to "loading" state while heavy process.
Yes, may be that will be even better for tiny interfaces, but you will still see an interface on background, it should be faded, to make accent that something going. Preloading window could be a base for future network actions in engine like "online authorization", how to deal just with one cursor if happened an network error? The user will already be prepared for where to view the information if he see that preloading window in other situations like I described above. For now you can't see in UI: have you broken map files or not, just only in system logs(stdout/stderror streams) you can see that information. In a preloading window we will have possibility to show some additional information for user, or give him an cancelling control. For now it can be hard to make in one PR, because I don't hear anything about "programming contexts" in c++, while I know how it should be about that from golang.
For now it can be hard to make in one PR, because I don't hear anything about "programming contexts" in c++, while I know how it should be about that from golang.
In C++, this kind of functionality is usually provided by frameworks/libraries that are used to implement asynchronous networking operations, such as Asio.
that's the huge problem of c++ to me: there are always too many ways to do the same thing. By other words: lots of frameworks implement too much of same things. Time passed and accepted new standarts without standard features needed every developer. Found useful example, the author operates with feature
and atomic
headers to implement "context".
How the cancel button should behave:
- it should be always visible, with possibility to player click it in any time
- it should be disabled for timeout, then enabled and give player possibility to click it
it should be regular rectangle button, or something like small square button with [x] sign in right upper corner?
Hi @shprotru , I don't think we should discuss C++ in general here. Every language has its own purpose.
Time passed and accepted new standarts without standard features needed every developer.
Every developer has its own set of "needed standard features". For me, it's better to have reflection (at least compile-time) as a language feature instead of something that could already be implemented using existing primitives such as threads or, in C++20, coroutines (and which is already implemented by various libs and frameworks).
How the cancel button should behave:
What exactly this button should currently cancel?
What exactly this button should currently cancel?
I am trying to describe universal UI control for long tasks, which could be used in several places, in which all the user has to do is just wait for them to finish, but some tasks could be cancelled by user. May be his awaiting could be so long, he would get hungry and prefer to turn off the game and go out to eat. For this situations, I think, would be nice to provide him a cancel button.
Hi @shprotru , did @oleg-derevenetz change solve your issue?
Nope, the problem is not solved, I record video about this problem, with software rendering cursor it's more visual:
https://user-images.githubusercontent.com/53114202/226164998-2475407e-677c-4b69-b20a-5a60a2f9bfeb.mp4
throughout the video, I made circular movements with the mouse, you can clearly see the moments of hanging
with disabled software cursor rendering there is less hangings, but it does not solves the problem. There is only one way to solve the problems with io - it is showing the window with preloader.
There is only one way to solve the problems with io - it is showing the window with preloader.
How this window will solve the inability to move the software cursor during disk i/o? The maximum it can do is to show the user that "something is going on, please wait" so that a user does not worry. But I don't see anyone really worried about a delay lasting ~1 second. BTW, many user interfaces that I remember show "please wait" windows only if the delay exceeds some threshold (maybe ~3-5 seconds). I propose to postpone such windows until we really need them (for example, when will some kind of network interaction be implemented).
The hanging is obvious, you see, it takes some time. And if I'll take slower disk drive, or putting more maps(than 1236 as right now) in a maps directory, then time of hanging will increase.
To avoid cursor hanging we can separate rendering and io operation on 2 threads, currently, seems rendering and file listing is going at single thread.
And this is how we can say user that something is going on right now
:
- As @Branikolog proposed, to make cursor as sundial icon.
- My idea: make small window with animated sundial icon, with some information about going process like text
loading maps, wait please
. And my proposal will have a logical development on other events that cause delays. They will definitely appear in the future.
To avoid cursor hanging we can separate rendering and io operation on 2 threads, currently, seems rendering and file listing is going at single thread.
This would be justified if the user could do something else useful at this time besides moving the cursor :) But the UI flow does not provide any opportunities of such kind. All the user can do is to wait for map list to load and maybe watch some "please wait" window. I don't even know how useful it will be with the current delay values of a ~1 second. I still think that such windows should be implemented later when there is real job for them (networking).
Hello everyone,
It is true that the loading time of the list of scenarios can be quite long. In the example, about three seconds for less than three hundred scenarios (antivirus disabled, Windows 7, 64 bits). On the other hand, it does not seem to have a problem with mouse cursor lag.
In fheroes2:
https://user-images.githubusercontent.com/43583994/226196753-c7fcd77f-8d00-405f-b69f-fad632413736.mp4
I assume that the program checks all the files one by one to validate these files?
Since this is something that the player is not going to change every five minutes, why not have some sort of pre-list of available scenarios. The program checks if the number of files and if the total weight of the files has changed (or whatever), if so it checks all the files, otherwise the pre-list is loaded.
If by pure coincidence the user has made changes in the scenario folder and the number and weight of the files is the same, and the user tries to launch a scenario that does not exist, the program automatically checks all the files and update the list of scenarios and the pre-list.
If the player does not find a scenario, that he has just added, in the list of scenarios of the Select Scenario window, there is a graphical "REFRESH" button (so that it does not have to be translated and generated in several languages) that makes the program to check all the files and to update the list of scenarios and the pre-list.
Select Scenario window:
Ho @LeHerosInconnu !
it does not seem to have a problem with mouse cursor lag
do you try to play with fheroes2.cfg
config file, parameter cursor soft rendering
, in which state it is on your machine?
pre-list of available scenarios
because this is a way to additional memory consumption, which will negatively affect weak devices. How about placing 1236 map files to engine-supported weak devices, like psp, I think it will longer hanging.
Despite of fact that this might be an issue for some players most of them don't have thousands of files in MAPS directory. Therefore, I marked this issue as low priority and we address it in the future.
Hello @shprotru,
Ho @LeHerosInconnu !
it does not seem to have a problem with mouse cursor lag
do you try to play with
fheroes2.cfg
config file, parametercursor soft rendering
, in which state it is on your machine?
No, but with cursor soft rendering
set to "on" there is a lag.
In fheroes2:
https://user-images.githubusercontent.com/43583994/226219269-3eaa162c-c9c0-4b84-9df8-c9c9fc19364f.mp4
pre-list of available scenarios
because this is a way to additional memory consumption, which will negatively affect weak devices. How about placing 1236 map files to engine-supported weak devices, like psp, I think it will longer hanging.
If the list of scenarios is in a text file (or similar, and possibly compressed), it should be faster to access a single file than hundreds, or a thousand files?
Hi @LeHerosInconnu and @shprotru , this issue cannot be solved properly without introduction on separate threads usages (within the game engine). While there is a delay in opening certain UI windows in the game this issue marked right now as low priority as the amount of changes required to make it work is not valuable at the moment. We can come back to this issue once we have less high priority issues.
Hi @shprotru and @LeHerosInconnu , the latest build should be slightly faster as we changed the logic of reading files from hard disc.
@shprotru and @LeHerosInconnu , did you check the latest build? Is it smoother than before?
These lags are caused by the fact that game should open every map to read its header to get the info about number of players, win/loss conditions, description, etc, and this can take some time, if there are hundreds of them (at least until the corresponding file fragments are not in OS cache). There is not much can be done (apart from displaying some "please wait" window maybe, but most users have SSD/flash now, so...).
Hi @ihhub situation not changed, in attached video how it looks for game player. maps.selection.loading.mp4.zip
Hi, @shprotru
Hi @ihhub situation not changed, in attached video how it looks for game player. maps.selection.loading.mp4.zip
The file is not working for me.
The file is not working for me.
Hi, @Branikolog send you this video as PM to discord.