Skip to content

Commit f0883cd

Browse files
llyyrkasper93
authored andcommitted
wayland: call pl_color_space_infer before comparing target_params
Calling `pl_color_space_infer` on `wl->target_param` can cause the `pl_color_space_equal` check to fail on every frame if any values were changed by `pl_color_space_infer`. This will cause us to believe target_params get changed on every frame, and we'll end up in a state where wayland events happen in the following order indefinitely: -> wp_color_management_surface_v1#45.set_image_description(...) -> wp_color_management_surface_v1#45.unset_image_description() -> wl_surface#9.commit() -> wp_color_management_surface_v1#45.set_image_description(...) -> wp_color_management_surface_v1#45.unset_image_description() -> wl_surface#9.commit() Since image_description is double buffered, we always queue an unset to the pending state before each commit. As a result, no commit ever carries a valid image_description. Taking the sample file in the issue as an example, we end up in this state because the file has `min_luma == 0` but `pl_color_space_infer` normalizes this value to `min_luma == 0.000001`. This makes it so that we store a different `target_param` to `vo_wayland_state` on every frame than the one received from `vo_get_target_params`. So we end up setting image description on every frame in this case. The key problem here is that `set_color_management` isn't blocking the thread until `set_image_description is called`, so vo->driver->flip_page is called before this finishes. This commit fixes the problem by doing any operations that could change `wl->target_param` first before doing any equality checks to skip changing to image description pointlessly. This fixes the problem in the issue that image_description is never set on such files. The synchronization problem is fixed in a later commit, because otherwise setting image_description on every frame could have adverse frame time effects Fixes: #16825
1 parent 3020439 commit f0883cd

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

video/out/wayland_common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3467,7 +3467,6 @@ static void set_color_management(struct vo_wayland_state *wl)
34673467
wp_image_description_creator_params_v1_set_primaries_named(image_creator_params, primaries);
34683468
wp_image_description_creator_params_v1_set_tf_named(image_creator_params, transfer);
34693469

3470-
pl_color_space_infer(&wl->target_params.color);
34713470
struct pl_hdr_metadata hdr = wl->target_params.color.hdr;
34723471
bool is_hdr = pl_color_transfer_is_hdr(color.transfer);
34733472
bool use_metadata = hdr_metadata_valid(&hdr);
@@ -4135,6 +4134,7 @@ void vo_wayland_handle_color(struct vo_wayland_state *wl)
41354134
if (!wl->vo->target_params)
41364135
return;
41374136
struct mp_image_params target_params = vo_get_target_params(wl->vo);
4137+
pl_color_space_infer(&target_params.color);
41384138
if (pl_color_space_equal(&target_params.color, &wl->target_params.color) &&
41394139
pl_color_repr_equal(&target_params.repr, &wl->target_params.repr) &&
41404140
target_params.chroma_location == wl->target_params.chroma_location)

0 commit comments

Comments
 (0)