Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
LibVLCSharp
LibVLCSharp
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 76
    • Issues 76
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 0
    • Merge Requests 0
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • VideoLAN
  • LibVLCSharpLibVLCSharp
  • Issues
  • #384

Closed
Open
Opened Aug 06, 2020 by SkinnySackboy@SkinnySackboy
  • Report abuse
  • New issue
Report abuse New issue

Object reference not set to an instance of an object when resizing window

Summary

Exceptions thrown when using a docking framework (such as Infragistics Dock Manager). The video still carries on playing and everything works, it's just that some unhandled exceptions are thrown as you tear out and re-dock windows, presumably as their parent changes. Note that the example requires the use of an Infragistics library which I am not able to provide, but which you can create a trial account for to see the expected result.

Minimal project and steps to reproduce

In the attached project, you need to click on one of the tabs and drag it out, re-dock it, repeat. Before doing so, make sure you have all exception catching checked in Visual Studio. Also, inside Main.xaml.cs you need to replace @"ADD VIDEO LINK HERE" with an actual video.

ReproVLCIssue.zip

What is the current bug behavior?

My feeling is that as you drag components out and re-dock them, the window owner changes, which causes two kinds of exception to be thrown. To be clear, they don't always both happen deterministically, but are still pretty easy to reproduce.

  1. The issue in this case is that in this 'Wndhost_SizeChanged' we call 'var source = PresentationSource.FromVisual(_wndhost);' but source in these cases ends up being assign to null, which subsequently causes this exception to be thrown. System.NullReferenceException: Object reference not set to an instance of an object. at LibVLCSharp.WPF.ForegroundWindow.Wndhost_SizeChanged(Object sender, SizeChangedEventArgs e)

  2. This is the second error we see, which is effectively because in the method 'Background_Loaded' at the end of the try statement we try to call Show(), but the window has already been hidden and so according to WPF this operation is illegal. The reason the exception below is misleading is because the code reads 'throw new VLCException("Unable to create WPF Window in VideoView.");' without re-propagating the actual exception that led to this point. LibVLCSharp.Shared.VLCException: Unable to create WPF Window in VideoView. at LibVLCSharp.WPF.ForegroundWindow.Background_Loaded(Object sender, RoutedEventArgs e)

What is the expected correct behavior?

Exceptions not being thrown, otherwise it is working perfectly well.

Does it work on other plaforms? Does it work with the official VLC apps?

This is to do with the WPF wrapper and not with VLC.

Relevant logs and/or screenshots

Exception 1

Error

Exception 2

Error2

Environment

  • OS: Windows 10 x64 1909
  • Device: Windows machine
  • LibVLC 3.0.11, x64
  • LibVLCSharp 3.4.6

Possible fixes

  1. In 'Wndhost_SizeChanged', if source is assigned to null we need a null guard to break out of the method
  2. In 'Background_Loaded' we should not attempt to call Show() once the Window has already been closed, so this could be a symptom of the Loaded event having fired at an unexpected moment
  3. In 'Background_Loaded' in general it would be useful to catch the exception and include in the re-propagated exception, otherwise any exceptions caught here are misleading as we discard any information that led to this point
Edited Aug 07, 2020 by SkinnySackboy
To upload designs, you'll need to enable LFS and have admin enable hashed storage. More information
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
1
Labels
needs info
Assign labels
  • View project labels
Reference: videolan/LibVLCSharp#384