oprypin / crsfml

Crystal bindings to SFML multimedia/game library

Home Page:https://oprypin.github.io/crsfml

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Periodic lags due to (possibly) GC

konovod opened this issue · comments

commented

First of all, thanks for the great work.
When i've tried even simplest examples (e.g. a flippy_bird, though it is more visible on a less dynamic example, so i commented line that move bird and it only rotates), i see about half-second lags every several seconds.
I wonder if anyone experience these lags too or problem is just in my PC. In the latter case the issue perhaps should be closed as my linux distro have some compatibility issues irrelevant to the library.

Hello, thanks for checking out the library.
To better see what's going on here, please try this example:

require "crsfml"

window = SF::RenderWindow.new(SF::VideoMode.new(800, 600), "Bird")

# window.vertical_sync_enabled = true

bird_texture = SF::Texture.from_file("resources/bird.png")

bird = SF::Sprite.new(bird_texture)
bird.scale = SF.vector2(3, 3)
bird.origin = bird_texture.size / 2.0
bird.position = SF.vector2(400, 300)

clock = SF::Clock.new

while window.open?
#   while event = window.poll_event()
#     window.close() if event.is_a? SF::Event::Closed
#   end

  bird.rotation = clock.elapsed_time.as_seconds * 150

  window.clear SF::Color.new(112, 197, 206)
  window.draw bird
  window.display()
end

And then try it with the first line that's currently commented out, and then try it with the 2nd commented group of lines present.
See if you can find which one lags worse.

(spoiler: if the 2nd group makes no difference, it's probably not GC)

commented

Well, all variants lags approx. at same rate (once per turn), so probably problem in my video driver or something. Should i close an issue?

@konovod It's not conclusive. If it's not a big bother, I'd really like you to try such an example with C++ SFML. (example coming up)

commented

Lol, just found same problem with glxgears. So it's definitely not SFML. Sorry for taken time.