Bug 55188 - WKWebViewConfiguration not being applied
Summary: WKWebViewConfiguration not being applied
Status: RESOLVED ANSWERED
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: XI 10.10 (d15-2)
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-04-13 15:27 UTC by Dustin
Modified: 2017-05-21 18:49 UTC (History)
4 users (show)

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


Attachments
My WKWebView Factory (1.53 KB, application/octet-stream)
2017-04-13 15:27 UTC, Dustin
Details
C# Simplified Test Case (10.45 KB, application/zip)
2017-05-21 18:48 UTC, Vincent Dondain [MSFT]
Details
Swift Simplified Test Case (21.24 KB, application/zip)
2017-05-21 18:49 UTC, Vincent Dondain [MSFT]
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 ANSWERED

Description Dustin 2017-04-13 15:27:20 UTC
Created attachment 21516 [details]
My WKWebView Factory

My problem is that I have a WKWebViews that contain video URL's and they auto play full screen no matter what the setting are in the WKWebViewConfiguration.

What I assume is the problem is that recently Apple deprecated several properties on WKWebViewConfiguration such as 'requires​User​Action​For​Media​Playback' and 'mediaPlaybackRequiresUserAction'(as seen here: https://developer.apple.com/reference/webkit/wkwebviewconfiguration). 

Setting these values used to work in iOS 10.2 and below, but it does not work on iOS 10.3. I have added the new property 'mediaTypesRequiringUserActionForPlayback' set to all (or none, neither value changes anything).

I also have never gotten 'allowsInlineMediaPlayback' to be applied and actually work. 

My guess as to what is happening is that you guys added the new properties but still only honor the deprecated properties.

Attached I have a util class where I am creating my WKWebViews.
Comment 1 Timothy Risi 2017-04-13 18:09:18 UTC
Hello,

Please include your full build logs, crash reports (if any), test case (to reproduce) and all version informations.

 The easiest way to get exact version information is to use the "Xamarin Studio" menu, "About Xamarin Studio" item, "Show Details" button and copy/paste the version informations (you can use the "Copy Information" button).
Comment 2 Dustin 2017-04-13 20:11:17 UTC
1. Create a WKWebViewConfiguration.
 - Set all proporties you can to make it so that the use would have to click on the video to make it play (requires​User​Action​For​Media​Playback, mediaPlaybackRequiresUserAction, and mediaTypesRequiringUserActionForPlayback)
2. Add the webview to a view controller
3. Load a video url (Example video url: https://s3-us-west-2.amazonaws.com/fanreact-rtmp-video-stream/9693_116_11_2_16_18_40.mp4)
 - PostWebView.LoadRequest(new NSUrlRequest(new NSUrl(url), NSUrlRequestCachePolicy.ReturnCacheDataElseLoad, 40));

You will notice that one the video is loaded, it will automatically fullscreen and start playing the video even though we are saying in the WKWebViewConfiguration that it must have user interaction to start playing. 


Version info:
Xamarin Studio Community
Version 6.3 (build 863)
Installation UUID: f30ba685-40c4-4f4d-92fa-0c4bbc84716b
Runtime:
	Mono 4.8.1 (mono-4.8.0-branch/22a39d7) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 408010000

NuGet
Version: 3.5.0.0

Xamarin.Profiler
Version: 1.4.0
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

Apple Developer Tools
Xcode 8.3.1 (12170)
Build 8E1000a

Xamarin.iOS
Version: 10.8.0.175 (Xamarin Studio Community)
Hash: a04678c2
Branch: d15-1
Build date: 2017-03-28 14:05:38-0400

Xamarin.Android
Version: 7.2.0.7 (Xamarin Studio Community)
Android SDK: /Users/dustinwilliams/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		6.0 (API level 23)

SDK Tools Version: 25.2.3
Comment 3 Vincent Dondain [MSFT] 2017-05-21 18:48:13 UTC
Hi Dustin,

I did a bit of research and I couldn't figure out how to prevent autoplay for videos either.

After the move from UIWebView to WKWebView it seems Apple deprecated the APIs that should be used to prevent autoplay: https://developer.apple.com/reference/webkit/wkwebviewconfiguration

I created a quick Swift project (see attachements) to ensure it's not a Xamarin specific bug to answer your:

"My guess as to what is happening is that you guys added the new properties but still only honor the deprecated properties."

Xamarin.iOS is a very thin layer on top of the native iOS frameworks and the 2 test cases (C#/Swift) show absolutely identical behaviors.

Also about: "Setting these values used to work in iOS 10.2 and below, but it does not work on iOS 10.3.".

Actually I would say setting those values didn't work as well but rather the autoplay setting (of the WKWebView, defined internally by Apple) was off.

You can check that by commenting the 3 properties defined for the WKWebViewConfiguration (in both test cases) and see that with nothing defined at all, the video won't auto play (when it does autoplay with nothing defined on iOS 10.3).

I cannot help any further since this is a native issue and I only have as much information as you (Apple API doc) with regard to how WKWebView works (:

I can only tell you this is not a Xamarin-specific bug so I will close this issue.

Filing a radar (bug) with Apple [0] or asking the broader developer community would be the best and quickest place for additional troubleshooting help on this issue.
Posting a question on Stack Overflow [1] or the Xamarin Forums [2] would be the best next step.

[0] https://developer.apple.com/bug-reporting/
[1] http://stackoverflow.com/questions/tagged/xamarin
[2] https://forums.xamarin.com/
Comment 4 Vincent Dondain [MSFT] 2017-05-21 18:48:45 UTC
Created attachment 22334 [details]
C# Simplified Test Case
Comment 5 Vincent Dondain [MSFT] 2017-05-21 18:49:09 UTC
Created attachment 22335 [details]
Swift Simplified Test Case