0 votes

Short version: When I try to retrieve the millisecond before a frame is drawn and the msec after it, I get the same result.

According to: https://docs.godotengine.org/en/stable/classes/class_visualserver.html, the framepredraw signal is emitted before a frame is drawn and framepostdraw is emitted after. I use this code to get the time in milliseconds when the signals are emitted and they both show the same time.

extends Node

var after
var before


func _ready():
    var ret = VisualServer.connect("frame_pre_draw", self, "_pre_draw")
    ret = VisualServer.connect("frame_post_draw", self, "_post_draw")

    return ret


func _post_draw():
    after = OS.get_ticks_msec()
    print("after:" + str(after))


func _pre_draw():
    before = OS.get_ticks_msec()
    print("before: " + str(before))

This returns:
before: 2543
after: 2543

Help ? bug ? gone wrong ? To be continued ?
Amerika exbrain

in Engine by (156 points)

1 Answer

0 votes

To me this doesn't seem like a bug. If very little is happening between pre and post draw methods, they could very easily happen within the same millisecond. Use the microseconds method instead (getticksusec()) and see what happens.

by (212 points)

Impossible. The 3D scene is running at 90 frames per second (on my integrated Intel HD). For this to be correct it would mean that the scene is running at 1000+ frames per second.

While I was experimenting with the engine I also found out that the process runs before a scene is rendered except if you lock the texture of the viewport for reading. If you use the lock() on the texture.getdata() of the viewport the results are correct (it does show msec after the scene is rendered and drawn) but the frame rate is halved and turns every 60 fps scene into a slide show.

I went back to check your theory and this time I also included the time my _process begins. It is still broken while the lock() method works. My results from the signals method:

_process: 2373
before: 2373
after:2373

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.