Baseflow / Baseflow/XamarinMediaManager

[UWP] Main Thread Error playing Mp3 when extracting mp3 album cover.

Open
#694 2 comments 0 reactions 0 assignees View on GitHub
bug help wanted need investigation
Dominant language
C#
Stars
763
Forks
299
PR merge metrics
No merged PRs in 30d

Description

## 🐛 Bug Report

Hi, I have some issue with the player. I am making a Xamarin Forms app completly running async
I am testing on a UWP App for the desktop.

System.Exception: The application called an interface that was marshalled for a different thread. (Exception from HRESULT: 0x8001010E (RPC_E_WRONG_THREAD))\r\n at Windows.UI.Xaml.Media.Imaging.BitmapImage..ctor()\r\n at MediaManager.Platforms.Uap.Media.StorageFileProvider.ProvideImage(IMediaItem mediaItem)\r\n at MediaManager.Media.MediaExtractorBase.GetMediaImage(IMediaItem mediaItem)\r\n at MediaManager.Media.MediaExtractorBase.UpdateMediaItem(IMediaItem mediaItem)\r\n at MediaManager.Media.MediaExtractorBase.CreateMediaItem(String url)\r\n at MediaManager.Media.MediaExtractorBase.CreateMediaItem(FileInfo file)\r\n at MediaManager.MediaManagerBase.Play(FileInfo file)\r\n at
...

Now I looked a bit in the sourcecode and the Problem seems to be when extracting the album cover the BitmapImage is created asyncronusly but the BitmapImage is a old Windows class which needs to be executed on the main thread.

I already tried calling it from MainThread.InvokeOnMainThreadAsync but that doesn't help since the bitmap is extracted asyncronosly.

Now I am suprised that this error hasn't happend before. Also it seems not to happen with all mp3s
which have covers only with certain.

Here is a mp3 where the error can be reproduced:
https://1drv.ms/u/s!AkY5QCCnUjHgiOYzAzWc3Lybpav3gw?e=mKipiD

### Expected behavior
Plays

### Reproduction steps
Create a new UWP App.
Calll player.Play(new FileInfo(contentFullPath)); with the mp3 with album cover proced before.

Try multiple times to quickly after each other to play one file

### Configuration

**Version:** 0.96 - not the 0.97 since I still use Android 9.0 and UWP Build 18362 not 10.0 since I cannot use it.

**Platform:**
- [ ] :iphone: iOS
- [ ] :robot: Android
- [ ] :checkered_flag: WPF
- [X] :earth_americas: UWP
- [ ] :apple: MacOS
- [ ] :tv: tvOS
- [X] :monkey: Xamarin.Forms

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.