Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Strangest sf::sleep bug  (Read 17949 times)

0 Members and 1 Guest are viewing this topic.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Strangest sf::sleep bug
« Reply #15 on: February 18, 2013, 07:55:29 pm »
Quote
the same effect as opening chrome.
Which is? To solve the problem? (sorry, I don't really remember the begining of this discussion)
Laurent Gomila - SFML developer

Daddi

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
    • http://foxdev.de/
    • Email
Re: Strangest sf::sleep bug
« Reply #16 on: February 18, 2013, 11:07:28 pm »
Yes, the moment the chrome browser starts, the bug seems to vanish.
Could it be, that chrome sets windows sleep-time temporarily down to 1 (instead of 15.6 which was named earlier) and back after it gets closed?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Strangest sf::sleep bug
« Reply #17 on: February 18, 2013, 11:10:51 pm »
Quote
Could it be, that chrome sets windows sleep-time temporarily down to 1 (instead of 15.6 which was named earlier) and back after it gets closed?
I don't know. It could be, yes.
Laurent Gomila - SFML developer

cire

  • Full Member
  • ***
  • Posts: 138
    • View Profile
Re: Strangest sf::sleep bug
« Reply #18 on: February 19, 2013, 08:16:31 am »
It would seem that it does.

Some interesting info here.
« Last Edit: February 19, 2013, 08:19:06 am by cire »

Daddi

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
    • http://foxdev.de/
    • Email
Re: Strangest sf::sleep bug
« Reply #19 on: February 19, 2013, 10:33:44 am »
Thats very intersting! But I wonder, why this doesn't happen on every windows machine. At home, everythings fine, at work -> sleep "bug".

Foaly

  • Sr. Member
  • ****
  • Posts: 453
    • View Profile
Re: Strangest sf::sleep bug
« Reply #20 on: February 19, 2013, 10:55:49 am »
Wow this is a very interesting article! So using timeBeginPeriod(1); seems to be quiet common for using high resolution timer/sleep.

Daddi

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
    • http://foxdev.de/
    • Email
Re: Strangest sf::sleep bug
« Reply #21 on: February 19, 2013, 11:33:20 am »
The earlier posted fix sets timeBeginPeriod every time before a single sleep is engaged. A better solution may be to do this once during the initialization of the application.

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: Strangest sf::sleep bug
« Reply #22 on: February 23, 2013, 02:06:59 am »
So that when the application terminates in some undefined way, the system gets stuck in high resolution mode? Changing the mode does not incur that much of a performance penalty and since it is used during sf::Sleep, whether that time is spent setting the mode or sleeping doesn't really matter.
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

Daddi

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
    • http://foxdev.de/
    • Email
Re: Strangest sf::sleep bug
« Reply #23 on: February 25, 2013, 06:15:41 pm »
True, I didn't think of this. But theoretically, this could happen with chrome too :)

Foaly

  • Sr. Member
  • ****
  • Posts: 453
    • View Profile
Re: Strangest sf::sleep bug
« Reply #24 on: July 29, 2013, 08:37:15 pm »
Im sorry for reactivating this old topic. I know it's not a good practice, but since there where quiet a few topics recently about sf::sleep being a bit off (for example through setFramerateLimit() ) I remembered this thread. I dug it up and saw that there was quiet a lot of information gathered and even a solution proposed, but the problem was never actually solved. So shouldn't we investigate further or at least create a ticket on the tracker?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Strangest sf::sleep bug
« Reply #25 on: July 29, 2013, 09:09:05 pm »
So shouldn't we investigate further or at least create a ticket on the tracker?
Hehe, I was thinking the same, but didn't go looking for the thread. Would be nice if we can find a good solution. :)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Foaly

  • Sr. Member
  • ****
  • Posts: 453
    • View Profile
Re: Strangest sf::sleep bug
« Reply #26 on: July 29, 2013, 10:30:37 pm »
Hehe, I was thinking the same, but didn't go looking for the thread. Would be nice if we can find a good solution. :)
Good to hear! So I am not the only one :) I created an issue on the tracker: #439

Cornstalks

  • Full Member
  • ***
  • Posts: 180
    • View Profile
    • My Website
Re: Strangest sf::sleep bug
« Reply #27 on: July 30, 2013, 02:58:27 pm »
Hehe, I was thinking the same, but didn't go looking for the thread. Would be nice if we can find a good solution. :)
Good to hear! So I am not the only one :) I created an issue on the tracker: #439
I personally think a "high resolution sleep" is a bad idea, as it's very platform dependent, and on some platforms completely impossible.

I think instead something that yield's the current thread's timeslice back to the system would be much more effective. (i.e. SwitchToThread() on Windows (not Sleep(0), which is different)); this would be most useful for programs that don't want to unnecessarily max out the CPU (like mobile devices, where battery is important).