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

Bugs/sdl gettick reset #7

Draft
wants to merge 11 commits into
base: knulli
Choose a base branch
from

Conversation

bremedios
Copy link

Fix usage of SDL_GetTicks() throughout ES. This is separate from the issue causing the Battery % as these changes can have a more widespread impact.

The general fix is to convert from using SDL_GetTicks() which can be reset to 0 to use std::chrono::steady_clock.

bremedios and others added 2 commits November 23, 2024 10:36
- Changed SDL_GetTicks() to be std::chrono::steady_clock::now()
- Changed how totalTime is calculated.
  - Original
    - totalTime has the total time elapsed since the start of the event loop on
      each loop so it will be a larger time than the time since the start if it
      iterates more than once in the loop.
  - Changed:
    - totalTime is only the time elapsed since the start of the event loop.
@bremedios
Copy link
Author

playVideo within es-app/main.cpp

Changes

  • total time continually has the total time since the start added to it, instead of time since the last addition. This appears to be a bug because it makes totalTime larger than it should be as well as being inconsistent. Total time will now be the total number of milliseconds since the start of the loop.
  • Uses std::chrono::steady_clock to determine how much time (milliseconds) has passed.

I'm not sure if we would ever launch a program that would cause the SDL_GetTicks() to be reset while we're playing a video so although this "could" result in an issue if not fixed, I'm not sure if this would be experienced.

- Changed usage of SDL_GetTicks() to std::chrono::steady_clock
@bremedios
Copy link
Author

main within es-app/main.cpp

Changes

  • Changed usage of SDL_GetTicks() to std::chrono::steady_clock

Potential Impacts

  • Used to determine if it should skip calls to SDL_WaitEventTimeout() and SDL_PollEvent()
  • Used to determine if guns should be updated
  • Used as the change in time when calling Window::update()

- ScraperHttpRequest & ImageDownloadHandle
  - Converted from SDL_GetTicks() to std::chrono::steady_clock
  - Code changed deals with hold off when HTTP 429/Too Many Requests
    is received and how the hold-off is handled.
@bremedios
Copy link
Author

ScraperHttpRequest/ImageDownloadHandle

Changes

  • Changed usage of SDL_GetTicks() to std::chrono::steady_clock

Original code

  • Could wait longer than it should to retry a http request if the SDL Tick is reset after the query but before the hold-off expires (and the request is retried.)

Warning

  • This change is potentially dangerous and should be reviewed
  • This could impact the hold-off logic when we receive a notification for too many requests.

- Removed usage of SDL_GetTicks().  Code is not used and likely left
  over from some timing code to tell how long the .pdf extractions
  took at some point.
@bremedios
Copy link
Author

ApiSystem::extractPdfImages in ApiSystem.cpp

Changes

  • Removed usage of SDL_GetTicks() calls as they are no longer used. Likely left over from someones timing code to tell how long it took to extract and process the .PDF files.

- Converted from SDL_GetTicks() to std::chrono::steady_clock
@bremedios
Copy link
Author

ViewController::reloadAll

Changes

  • Changed usage of SDL_GetTicks() to std::chrono::steady_clock.

- Adjusted debug log (time to save) to std::chrono::system_clock from SDL_GetTick()
@bremedios
Copy link
Author

es-core: SystemConf::saveSystemConf

Changes

  • Changed debugging logging from using SDL_GetTicks() to std::chrono::steady_clock.

- Converted timing from SDL_GetTicks() to std::chrono::steady_clock
- Could potentially fix bugs in fading caused by SDL_GetTicks() being reset.
@bremedios
Copy link
Author

es-core: GuiInfoPopup::update

Changes

  • Changed usage of SDL_GetTicks() to std::chrono::steady_clock

Potential Bug Fixes

  • Its possible for there to be fade issues if the SDL tick is reset during the fade animation for anything using GuiInfoPopup.

- Converted from SDL_GetTicks() to std::chrono::steady_clock
- Use of SDL_GetTicks() could cause fade in not to work if the SDL Tick gets reset for things that use the Video component.
@bremedios
Copy link
Author

es-core: VideoComponent::handleStartDelay VideoComponent::update VideoComponent::startVideoWithDelay

Changes

  • Changed usage of SDL_GetTicks() to std::chrono::steady_clock

Potential Bug Fixes

  • It is possible for there to be fade issues if the SDL tick is reset during the fade animation. (if SDL tick is reset)
  • It is possible for it to take longer than it should to call GuiComponent::update (if SDL tick is reset)

@bremedios
Copy link
Author

bremedios commented Nov 24, 2024

Testing Notes: [5 of 9]

Will track testing status of the changes here.

VideoComponent

  • Not Started

GuiInfoPopup

  • Confirmed timing for SDL_GetTicks and std::chrono match up when running
  • Was able to hit the function when canceling a screen scrape.

Save System Config [Tested]

  • This is reporting taking 0ms when executing an NES emulator.

ViewController::Reloadall [Tested]

  • This can be triggered by changing the slideshow type Settings->User Interface Settings->Screensaver Settings
  • Timing is accurate and correct.

ApiSystem::extractPdf Images [Tested]

  • PDFs can be read via the library.

ScraperHttpRequest

  • Scrapping via Screenscraper works
  • Able to hit update() function
  • Not able to hit too many requests

ImageDownloadHandler

  • Scraping via Screenscraper works
  • Able to hit update() function
  • Not able to hit too many requests

Power Save in Main [Tested]

  • Confirmed timing for SDL_GetTicks and std::chrono match up when running

Playvideo in main [Tested]

  • Confirmed timing for SDL_GetTicks and std::chrono match up when running. Initial commit had a bug where ps_time was used instead of lastTime.

Bugs Created

Bradley Remedios and others added 2 commits November 24, 2024 03:19
- Fixed bug where ps_time was used instead of lastTime
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

Successfully merging this pull request may close these issues.

1 participant