Bug 13966 - Youtube embedded videos become unresponsive after playback controls disappear
Summary: Youtube embedded videos become unresponsive after playback controls disappear
Status: RESOLVED DUPLICATE of bug 21669
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: 6.4.0
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
: 15244 ()
Depends on:
Blocks:
 
Reported: 2013-08-14 04:34 UTC by Prashant Cholachagudda
Modified: 2014-07-30 10:01 UTC (History)
6 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Xamarin Test Case (6.53 KB, application/zip)
2013-08-23 22:17 UTC, Brendan Zagaeski (Xamarin Team, assistant)
Details
Xcode Test Case (26.56 KB, application/zip)
2013-08-23 22:17 UTC, Brendan Zagaeski (Xamarin Team, assistant)
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED DUPLICATE of bug 21669

Description Prashant Cholachagudda 2013-08-14 04:34:48 UTC
The embedded youtube video becomes unresponsive on the device (iphone) once after playback controls disappear.
User has to wait until playback is done to get the controls back.
Comment 2 ric3kg 2013-08-14 19:46:16 UTC
This problem is holding up a product that is otherwise ready for submission to the app store! Please help!
Comment 3 Brendan Zagaeski (Xamarin Team, assistant) 2013-08-23 22:17:03 UTC
Based on results from an iPad 3 (iOS 6.0) and iPhone 5 (iOS 6.1.4), it looks like the problem is somehow caused by the `GetSupportedInterfaceOrientations()` override in the `AppDelegate`. Commenting out this override fixes the problem for me.

Going the other direction, a minimal sample project that does not include a `GetSupportedInterfaceOrientations()` override does not show the problem. Adding the override introduces the problem. Example "Xamarin Test Case" attached.

Translating the example line-by-line to Objective-C, and then compiling and running with Xcode does *not* show the problem. Example "Xcode Test Case" attached.


Steps to reproduce:
1. Run the app.
2. Tap the YouTube video to start it playing.
3. Wait for the controls to disappear.
4. Tap anywhere on the screen to try to bring up the video playback controls.


Result:
The playback controls do not appear in the "Xamarin Test Case", but they do appear in the "Xcode Test Case". The result is the same on both the iPad and the iPhone.
Comment 4 Brendan Zagaeski (Xamarin Team, assistant) 2013-08-23 22:17:25 UTC
Created attachment 4705 [details]
Xamarin Test Case
Comment 5 Brendan Zagaeski (Xamarin Team, assistant) 2013-08-23 22:17:41 UTC
Created attachment 4706 [details]
Xcode Test Case
Comment 6 Brendan Zagaeski (Xamarin Team, assistant) 2013-08-23 22:44:00 UTC
Another partial work-around: using the `Info.plist` to restrict the App-wide orientations does not cause the problem.
Comment 7 ric3kg 2013-10-02 11:57:58 UTC
Has this bug been addressed in a later release. I'm not interested in a work around - that's not really fixing the problem.
Comment 8 Rolf Bjarne Kvinge [MSFT] 2013-10-11 06:39:48 UTC
This is a bug in iOS/Apple's code.

What happens is that when the app goes full-screen, iOS creates a temporary UIWindow covering the whole screen (which does not respond to tapping events, etc). This temporary UIWindow stays on top until it's freed, which happens quite quickly for normal iOS apps (since they usually don't retain it).

Xamarin.iOS will however create a managed wrapper for this temporary UIWindow when it's passed to GetSupportedInterfaceOrientations, and that managed wrapper will retain it.

Now this temporary UIWindow will stay on screen until the managed wrapper is freed by the GC. As an interesting consequence a (bad) workaround is to call GC.Collect a few times when the app goes fullscreen.

The bug is that iOS should not depend on the temporary UIWindow's lifetime, since user apps can in theory (and Xamarin.iOS apps do in practice) retain it and thus extend its lifetime.

For now adding this overload of GetSupportedInterfaceOrientations to your AppDelegate will work:

    [Export ("application:supportedInterfaceOrientationsForWindow:")]
    public UIInterfaceOrientationMask GetSupportedInterfaceOrientations (UIApplication application, IntPtr forWindow)
    {
        return UIInterfaceOrientationMask.Portrait;
    }

(and delete the existing overridden GetSupportedInterfaceOrientations implementation).
Comment 9 Rolf Bjarne Kvinge [MSFT] 2013-10-11 06:40:34 UTC
*** Bug 15244 has been marked as a duplicate of this bug. ***
Comment 10 Rolf Bjarne Kvinge [MSFT] 2013-10-11 07:26:52 UTC
Radar bug filed: 15206717
Comment 11 ric3kg 2013-10-11 11:31:28 UTC
This may work but how would the user rotate the device to see the YouTube video in Landscape?
Comment 12 ric3kg 2013-10-11 11:36:41 UTC
Also, once the video is exited, the app is non-responsive for several minutes. This is even after implementing the GC.Collect when the video loads. I don't think this bug is RESOLVED.
Comment 13 Rolf Bjarne Kvinge [MSFT] 2013-10-14 06:03:37 UTC
(In reply to comment #11)
> This may work but how would the user rotate the device to see the YouTube video
> in Landscape?

Sorry I wasn't clear, you can modify what the function returns as you wish, so this will work:

        return UIInterfaceOrientationMask.All; // or any other value

The important part is the function signature, not the actual code within.

(In reply to comment #12)
> Also, once the video is exited, the app is non-responsive for several minutes.
> This is even after implementing the GC.Collect when the video loads. I don't
> think this bug is RESOLVED.

Did you implement the GetSupportedInterfaceOrientations method as I explained in comment #8, or did you just add GC.Collect? The test case provided works fine for me after tapping Done if I implement GetSupportedInterfaceOrientations as I've explained.
Comment 14 ric3kg 2013-10-14 14:51:08 UTC
Has this bug been addressed in a later release. I'm not interested in a work around - that's not really fixing the problem.
Comment 15 Brendan Zagaeski (Xamarin Team, assistant) 2013-10-14 15:03:14 UTC
Unfortunately, the real, ideal fix for this will need to come from Apple. The Radar bug (15206717) is a bug that has been filed on Apple's bug tracking system, requesting that they fix this. That's why this bug has been marked as resolved upstream. The fix will need to come from Apple, "upstream" of Xamarin.

Rolf, feel free to correct me if I'm misstating this.
Comment 16 Rolf Bjarne Kvinge [MSFT] 2013-10-14 16:59:59 UTC
Brendan is entirely correct.
Comment 17 Rolf Bjarne Kvinge [MSFT] 2013-10-17 08:18:16 UTC
Since it's unlikely that Apple will fix their issue, I've implemented a workaround in Xamarin.iOS, so this should work in a future release (probably 7.0.4).

monotouch/master: 8d4ccb91dbbbda0dc3167856f80cc1e966d18b4a
Comment 18 Rolf Bjarne Kvinge [MSFT] 2014-07-30 10:01:06 UTC

*** This bug has been marked as a duplicate of bug 21669 ***