-
-
Notifications
You must be signed in to change notification settings - Fork 22k
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
Deactivate the CameraServer
by default.
#104232
Deactivate the CameraServer
by default.
#104232
Conversation
8d55644
to
5d94cdc
Compare
Just to add my two cents here, agree this is a good approach. I think having this as a properly exposed property is fine. Whether we set a property or call a setter, the effect remains the same, the delay on MacOS because we're (currently) not implementing this asynchronously or in a separate thread shouldn't be a factor here. Off course it would be great to do a follow up PR at some point to make the detection asynchronous or use a thread so we don't stall the app. It's been too long since I worked on this to know how feasible this change is but its worth investigating. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested locally (rebased on top of master
97241ff), it works as expected.
Benchmark
PC specifications
- CPU: Intel Core i9-13900K
- GPU: NVIDIA GeForce RTX 4090
- RAM: 64 GB (2×32 GB DDR5-5800 C30)
- SSD: Solidigm P44 Pro 2 TB
- OS: Linux (Fedora 41)
Time taken for an empty project to start and quit:
❯ hyperfine -iw1 -m50 "bin/godot.linuxbsd.template_release.x86_64.master --path /tmp/4 --quit" "bin/godot.linuxbsd.template_release.x86_64 --path /tmp/4 --quit"
Benchmark 1: bin/godot.linuxbsd.template_release.x86_64.master --path /tmp/4 --quit
Time (mean ± σ): 2.135 s ± 0.493 s [User: 0.210 s, System: 0.356 s]
Range (min … max): 1.581 s … 2.648 s 50 runs
Benchmark 2: bin/godot.linuxbsd.template_release.x86_64 --path /tmp/4 --quit <--- This PR
Time (mean ± σ): 1.654 s ± 0.150 s [User: 0.212 s, System: 0.351 s]
Range (min … max): 0.725 s … 1.770 s 50 runs
5873cc7
to
a2c5266
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may be a very painful thing to discover for some developers that upgrade to 4.5 so let's remember to make note of it
Add `monitoring_feeds` property to `CameraServer`. This saves resources for games that don't use a physical camera.
a2c5266
to
54685c3
Compare
Thanks! |
I profiled the launch of tps demo. I noticed that launching the
CameraServer
took 12% (120ms) of the total CPU time (on macOS). I found this curious because tps-demo should not access my camera.I propose deactivating the
CameraServer
by default. I think this is appropriate for most games: Most do not need to monitor cameras, and monitoring the feeds as a game that does not use cameras is questionable at best.The
CameraServer
can be activated in games that need it withset_is_monitoring_feeds
, and queried withis_monitoring_feeds
.Most games will not activate monitoring and thus won't pay for it. For games that do need the camera, I think it is still appropriate to be able to activate and deactive feed monitoring, because they may not need to monitor the feeds all the time.
Notes
This PR should be tested on Linux before merging. It should also be tested if the changes break camera monitoring, because I have no project to conveniently test it with.
It's also likely this PR (in its current state) will cause problems with the Godot editor itself, which may want to monitor feeds for editor purposes. I'm open to suggestions for where / how to support that.
This PR is a breaking change to games that use the camera feed. When they update, they'll need to start activating the server somewhere in their code.
Profiling
I profiled tps demo and found it to launch 8% (0.14s) faster on average on macOS:
Linux uses an asynchronous approach to monitoring feeds, so it should benefit asynchronously instead of on launch time.
Windows does not benefit because
CameraServer
is not implemented for it.Addendum
It may be appropriate to move the
CameraServer
to a GDExtension because it is very self-contained, and it is questionable that code to monitor cameras even ships with all Godot games in the first place.However, this is out of scope for this PR, and likely won't provide much more tangible benefit than what is suggested here (as the camera module is very small).