File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -73,6 +73,11 @@ void CameraFeedWeb::_on_denied_callback(void *context) {
73
73
bool CameraFeedWeb::activate_feed () {
74
74
ERR_FAIL_COND_V_MSG (selected_format == -1 , false , " CameraFeed format needs to be set before activating." );
75
75
76
+ // Initialize image when activating the feed
77
+ if (image.is_null ()) {
78
+ image.instantiate ();
79
+ }
80
+
76
81
int width = parameters.get (KEY_WIDTH, 0 );
77
82
int height = parameters.get (KEY_HEIGHT, 0 );
78
83
// Firefox ESR (128.11.0esr) does not implement MediaStreamTrack.getCapabilities(), so 'formats' will be empty.
@@ -87,6 +92,9 @@ bool CameraFeedWeb::activate_feed() {
87
92
88
93
void CameraFeedWeb::deactivate_feed () {
89
94
CameraDriverWeb::get_singleton ()->stop_stream (device_id);
95
+ // Release the image when deactivating the feed
96
+ image.unref ();
97
+ data.clear ();
90
98
}
91
99
92
100
bool CameraFeedWeb::set_format (int p_index, const Dictionary &p_parameters) {
@@ -124,8 +132,6 @@ CameraFeedWeb::CameraFeedWeb(const CameraInfo &info) {
124
132
feed_format.height = info.capability .height ;
125
133
feed_format.format = String (" RGBA" );
126
134
formats.append (feed_format);
127
-
128
- image.instantiate ();
129
135
}
130
136
131
137
CameraFeedWeb::~CameraFeedWeb () {
You can’t perform that action at this time.
0 commit comments