Skip to content

Avalonia: VideoView Content Bug

Summary

Found an issue with VideoView.UpdateOverlayPosition() not being called in certain circumstances when it should be. The bug is shown here where the unmodified VideoView's content remains in-place despite the changing layout:

Example

It only seems to occur when the view is shifted, it works properly on resizing and with window adjustments/drags. Note that it is only the VideoView Content that fails to update: the video playback window adjusts correctly.

Minimal project and steps to reproduce

The reproduced example and found solution can be found here. I discovered it like it is shown in the example, with the VideoView nested in two grids:

  <!-- Set up so that the left splitter shifts and the right one resizes -->
  <!-- Right Border, Splitter, VideoView, Splitter, Left Border-->
  <Grid ColumnDefinitions="50, 7, 500, 7, *">
        <Panel Grid.Column="0">...

        <GridSplitter Grid.Column="1">...

        <Grid Grid.Column="2" RowDefinitions="*">

            <vlc:VideoView Grid.Row="1">
                <Panel>...
            </vlc:VideoView>

        </Grid>

        <GridSplitter Grid.Column="3">...

        <Panel Grid.Column="4">...
  </Grid>

Though there may be more circumstances where it is a problem.

What is the current bug behavior?

VideoView.Content is not updated when shifted by grids.

What is the expected correct behavior?

VideoView.Content moves with the VideoView window/control.

Environment

  • OS: Manjaro Linux (Wayland)
  • Version 6.10.13-3-MANJARO
  • Avalonia 11.1.0
  • LibVLC 3.0.21, x64
  • LibVLCSharp 3.9.0

Possible fixes

The fixes I found are located here. Changes are to line 83, and 219-221

  1. Adding an event handler for VideoView.Visual.LayoutUpdated in InitializeNativeOverlay().
  2. Removing event handler for Visual.BoundsProperty.Changed as it's no longer needed.
  3. Adding to the guard clause in UpdateOverlayPosition() so LayoutUpdated doesn't pelt a IsVisible = false VideoView with updates; Layout is updated on being made visible.
Edited by Paxton Neustaeter
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information