locked
MediaComposition.RenderToFileAsync USUALLY fails to progress when Windows Phone App is opened as a Share Target

    Question

  • The Windows Phone 8.1 WinRT app I'm working on uses MediaComposition.RenderToFileAsync. In normal operation this works 100% of the time. BUT, most of the time when I share an image, say from the photos app, to my app, MediaComposition.RenderToFileAsync starts processing, but never gives me any progress and never completes. Here is some of my code:

    var encodingProfile = Windows.Media.MediaProperties.MediaEncodingProfile.CreateMp4(app.GetEncodingProfile); result = app.mediaComposition.RenderToFileAsync(fileToSave, MediaTrimmingPreference.Fast, encodingProfile); result.Progress = (theResult, progress) => Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { txtProgress.Text = Math.Round(progress).ToString() + "%"; progressBar.Value = progress; }); result.Completed = (failureReason, progress) => Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { if(failureReason.Status == AsyncStatus.Canceled) { app.TurnOffScreenActiveRequest(); } else if(failureReason.GetResults() == TranscodeFailureReason.None) {

    // successful render mBlnFinishedTranscoding = true; RenderingGrid.Visibility = Windows.UI.Xaml.Visibility.Collapsed; MyAppBar.Visibility = Windows.UI.Xaml.Visibility.Visible; PlayVideo(); app.TurnOffScreenActiveRequest(); } else { // failed new MessageDialog(resourceLoader.GetString("VideoCreationFailed")).ShowAsync(); app.TurnOffScreenActiveRequest(); } });

    So, like I said, this works 100% of the time in normal App operation when I start the app from the start screen or apps list. BUT when I share a photo with my app from the photos app or the camera, the app will work perfectly fine until the MediaComposition.RenderToFileAsync is started. Every once in awhile while testing it will actually work, but most of the time it will basically start the render, but never give me any progress and will never complete.

    When debugging when the problem occurs, result.Status = Started, result.ErrorCode = null

    Any ideas why this only happens when my app is used as a Share Target and what I can do to fix it?

    Monday, May 11, 2015 3:58 PM

Answers

  • Hello Mark,

    I've been working with the Media Creation architects and we can't determine if this behavior is expected or not. Our initial thought is that you don't have access to the underlying media libraries due to access restrictions from the share context. It appears that your app might inherit the capabilities of the calling app. This doesn't explain why an error isn't raised by the underlying media components though.

    I think this one is going to need quite a bit of debugging. This is probably out of scope for my forum efforts. If you absolutely need an answer to this I would recommend that you open a support incident and make sure to put my name in the title I'll pick it up and work directly with you. I'm sure we can figure out the root cause of this issue.

    http://aka.ma/storesupport

    Thanks,

    James


    Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Tuesday, June 2, 2015 1:05 AM
    Moderator

All replies

  • I am currently investigating this issue and would get back to you once I have some update.

    Abdulwahab Suleiman


    Monday, May 11, 2015 11:22 PM
    Moderator
  • Hello,

    Abdul asked me to take a look at this for you. I spent most of the day working on this. I can easily reproduce the problem but I have no clue why this is occurring. The token coming back from RenderToFileAsync is legitimate and stays in scope. This is a really strange problem and seems to be very specific to the MediaComposition engine. I just can't explain it.

    I've contacted a colleague on the MediaComposition team to see if he can shed some light on this strangeness. If he asks me for your repro code do I have your permission to share it with him?

    Thanks,

    James


    Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Thursday, May 21, 2015 11:42 PM
    Moderator
  • Hello,

    Abdul asked me to take a look at this for you. I spent most of the day working on this. I can easily reproduce the problem but I have no clue why this is occurring. The token coming back from RenderToFileAsync is legitimate and stays in scope. This is a really strange problem and seems to be very specific to the MediaComposition engine. I just can't explain it.

    I've contacted a colleague on the MediaComposition team to see if he can shed some light on this strangeness. If he asks me for your repro code do I have your permission to share it with him?

    Thanks,

    James


    Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Thank you for looking into this! Yes, you can share my code... I can't imagine you guys would steal it and use it as your own :).  

    In the meantime, there isn't anyway to programatically restart an app, correct? I figured that maybe if I could restart the app right after it gets shared to, then maybe it would work.

    Thursday, May 21, 2015 11:49 PM
  • Hello Mark,

    Correct apps can only be activated by the system.

    I'll let you know what I find out.

    Thanks,

    James


    Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Friday, May 22, 2015 1:07 AM
    Moderator
  • Hello Mark,

    Correct apps can only be activated by the system.

    I'll let you know what I find out.

    Thanks,

    James


    Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    James,

    I just wanted to check in on this.

    Thanks!

    Mark

    Thursday, May 28, 2015 2:36 PM
  • Hello Mark,

    I've been working with the Media Creation architects and we can't determine if this behavior is expected or not. Our initial thought is that you don't have access to the underlying media libraries due to access restrictions from the share context. It appears that your app might inherit the capabilities of the calling app. This doesn't explain why an error isn't raised by the underlying media components though.

    I think this one is going to need quite a bit of debugging. This is probably out of scope for my forum efforts. If you absolutely need an answer to this I would recommend that you open a support incident and make sure to put my name in the title I'll pick it up and work directly with you. I'm sure we can figure out the root cause of this issue.

    http://aka.ma/storesupport

    Thanks,

    James


    Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Tuesday, June 2, 2015 1:05 AM
    Moderator