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

Remove verbose prints from CameraServer on Linux due to being printed every second #97469

Merged

Conversation

Calinou
Copy link
Member

@Calinou Calinou commented Sep 25, 2024

Verbose prints were looking like this, with (camera name) is no video capture device being printed once per second (in both the editor and project):

Loading resource: res://polyhaven/gray_rocks_arm_1k.jpg
Using present mode: Enabled
OBS Virtual Camera is no video capture device

OBS Virtual Camera is no video capture device

OBS Virtual Camera is no video capture device

OBS Virtual Camera is no video capture device

We could alternatively find a way to print the message only once per device name, but it would be more involved. I can look into doing this if it'd help significantly with troubleshooting webcam-related issues.

Copy link
Contributor

@dsnopek dsnopek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

This makes sense to me in principle, although, I'm not personally that familiar with the CameraServer stuff.

@mhilbrunner
Copy link
Member

mhilbrunner commented Oct 20, 2024

Why not one of the ERR_PRINT_ONCE/WARN_PRINT_ONCE/ERR_PRINT_ONCE_ED macros? Couldn't we prepend the device to the message to make them unique? OBS Virtual Camera is no video capture device already fits this, and being printed once would potentially be useful?

@Calinou
Copy link
Member Author

Calinou commented Oct 22, 2024

Why not one of the ERR_PRINT_ONCE/WARN_PRINT_ONCE/ERR_PRINT_ONCE_ED macros? Couldn't we prepend the device to the message to make them unique?

The _ONCE effect applies to the call location, not the message's contents:

/**
* Prints `m_msg` once during the application lifetime.
*/
#define ERR_PRINT_ONCE(m_msg) \
if (true) { \
static bool first_print = true; \
if (first_print) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, m_msg); \
first_print = false; \
} \
} else \
((void)0)

This means that using variable contents in the message will still print the message only once per session. We could still make use of WARN_PRINT_ONCE(), but it would only warn you about the first encountered device that triggers the error message.

The more involved approach is to keep an array of discovered camera names and check if the warning has been printed for a given camera name.

@Repiteo Repiteo merged commit 8a134c5 into godotengine:master Dec 3, 2024
19 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Dec 3, 2024

Thanks!

@Calinou Calinou deleted the cameraserver-linux-remove-prints branch December 18, 2024 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants