move clipboard updates to a focus callback, perfs enh + stability fix #2334
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We had a curious issue for years where eye or world window would freeze on our production setup only. However moving the mouse over the frozen window would usually unfreeze it. The main issue was data loss, because the software was not processing camera frames and the network buffers would overflow.
After inspecting the stack when that freezing occurs, it seems that calls to
glfw.get_clipboard_string
sometimes hangs.This might be specific interactions with our software / hardware, or that in our config (FPS/ screen framerate) the clipboard was concurrently written/read by eye and world windows, causing the hangs.
In the meantime, profiling would show that a small but non-negligible portion of the CPU cycles would be spent querying the clipboard.
I here moved that call to the focus callback: the logic being, if the OS clipboard (not the pyglui one that seems separate IIUC) was modified, it is only happening if the focus was given to another window, so we can retrieve it only when the pupil window get focus again.
That way, the clipboard is not probed at the screen framerate and likelyhood of hangs is largely dimished. It also separates the processing loop from call to OS clipboard that seems likely to disrupt RT reqs of pupil.
Let me know if that makes any sense and if you want me to make changes.