Blazor Hybrid — .NET 8: Playing Videos in the Background — UI-Thread issue and an “Ugly” Solution
I am currently developing an app and working on improving the login screen. For app development, I am using Blazor Hybrid. To make the login screen more visually appealing, I decided to play a video in the background.
Note: The German version of this article is available at the following link: Click here
This, however, proved to be a challenge. After numerous attempts to play the video in the background on iOS, I finally succeeded, but with an ugly side effect: the app started to lag, and the video did not play smoothly. This usually indicates that the UI thread is being blocked. A major disappointment. However, this is likely something the excellent .NET MAUI team can fix in the future.
In this article you will find out how I identified the problem with a profiler and how I solved it with a workaround. Why am I simply using a workaround now? → Clearly, I have to finish and the video is only 20 MB in size.
Analyze the problem with the profiler:
To analyze the problem, I initially wanted to use JetBrains Rider dotTrace. Unfortunately, I found out that it only supports macOS and Windows programs in the .NET MAUI scenario. Fortunately, there is a great community that has developed the tool “.NET Meteor” for Visual Studio.