@@ -2075,8 +2075,28 @@ void MediaActor::build_media_list_info(caf::typed_response_promise<utility::Json
20752075 if (media_list_columns_info_ != *result) {
20762076 media_list_columns_info_ = *result;
20772077
2078- mail (utility::event_atom_v, media_display_info_atom_v, media_list_columns_info_)
2079- .send (base_.event_group ());
2078+ // Media display info has changed. Emit a change event so the UI can update.
2079+ // This is needed so that the columns in the media list update when metadata
2080+ // changes.
2081+
2082+ // Temporary hack ... this event_atom, media_display_info_atom message will hit
2083+ // the SessionModelUI (via the parent playlist of this media). In SessionModelUI
2084+ // it then looks up the corresponding Media item in it's internal model data and
2085+ // updates the data for media_display_info. However, if this media item hasn't
2086+ // quite yet been added to the SessionModelUI then the lookup is very slow and
2087+ // then fails, as it falls back to a brute force recursive search for the matching
2088+ // actor_address so it looks through the whole model.
2089+
2090+ // On MediaActor creation the media_list_columns_info_ is updated a coupld of
2091+ // times as the media item (and media sources) are built so we end up here.
2092+
2093+ // Thus if we add lots of media at once (e.g. building a playlist) xstudio can
2094+ // freeze due to all these recursive searches. We therefore don't want to emit
2095+ // these events until some time after the media item has been created.
2096+ if ((utility::clock::now ()-creation_time_) > std::chrono::seconds (5 )) {
2097+ mail (utility::event_atom_v, media_display_info_atom_v, media_list_columns_info_)
2098+ .send (base_.event_group ());
2099+ }
20802100 }
20812101 rp.deliver (*result);
20822102 }
0 commit comments