Add CameraServer feeds_updated signal, and document async behavior#108165
Add CameraServer feeds_updated signal, and document async behavior#108165Repiteo merged 1 commit intogodotengine:masterfrom
CameraServer feeds_updated signal, and document async behavior#108165Conversation
eba8332 to
36446f6
Compare
a5aa0f3 to
3792213
Compare
CameraServer.monitoring_feeds race condition and document async behavior
72aee69 to
f905263
Compare
733ff30 to
28431d0
Compare
There was a problem hiding this comment.
This isn't fully thread safe. But I'm noticing on reviewing SafeFlag that it's improperly implemented, and cannot be made truly thread safe. For the moment, this is probably fine. I'll address my SafeFlag concerns some other time.
CameraServer.monitoring_feeds race condition and document async behaviorCameraServer feeds_updated signal, and document async behavior
Ivorforce
left a comment
There was a problem hiding this comment.
Looks good from my perspective now.
Thanks for doing all the adjustments!
This still needs a review from @godotengine/xr though.
62e4dfc to
3a3f3c9
Compare
|
There are two issues with this camera application:
@onready var reload = $ReloadButton
var current_feed: CameraFeed
func _ready():
reload.pressed.connect(_on_pressed_reload)
func _on_pressed_reload():
if CameraServer.monitoring_feeds:
CameraServer.monitoring_feeds = false
await get_tree().process_frame
if not CameraServer.feeds_updated.is_connected(_on_feeds_updated):
CameraServer.feeds_updated.connect(_on_feeds_updated)
CameraServer.monitoring_feeds = true
func _on_feeds_updated():
var feeds = CameraServer.feeds()
if not feeds.is_empty():
var current_feed = feeds[0]
current_feed.frame_changed.connect(_on_frame_changed, ConnectFlag.CONNECT_DEFERRED | ConnectFlag.CONNECT_ONE_SHOT)
func _on_frame_changed():
// processing camera images
passTherefore, we want to update the |
This was already the case before the PR. I think it's out of scope to fix this (unless there's an easy solution).
This is bad, that should definitely be fixed.
That would remove the Linux platform's ability to auto-update camera feeds altogether. I don't think this is an acceptable regression. The above bug with the |
|
Understood. This PR will not address the |
If the issue exists on current master, this PR does not have to address it (though it would be good to). If you don't intend to, could you open an issue for it? |
7051485 to
103f27a
Compare
There was a problem hiding this comment.
Should the signal also be fired when all the feeds are removed?
There was a problem hiding this comment.
cameraIds is a temporary variable within this function to receive camera IDs from ACameraManager_getCameraIdList(). ACameraManager_deleteCameraIdList() releases that variable. Since we updated the camera feed before that point, we need to emit the feeds_updated signal.
0085b5d to
759bcaa
Compare
There was a problem hiding this comment.
I also meant to update the string value to camera_feeds_updated since in code a user would do:
CameraServer.camera_feed_added.connect(...)
CameraServer.camera_feed_removed.connect(...)
CameraServer.camera_feeds_updated.connect(...)
There was a problem hiding this comment.
Fixed the signal name. Also reverted the variable name back to the original.
274fa61 to
f016980
Compare
f016980 to
2560ddb
Compare
|
I had another look, changes look sensible to me. Good work! To release managers: While this is a new feature, its addition facilitates the new |
|
Thanks! |
fixed: #108136
This ensures camera feeds are properly initialized before being accessed and prevents potential crashes from concurrent thread creation.