35

Just updated to Xcode 7 and iOS 9 SDK and found a problem when playing the HTML 5 video in the UIWebview. The code is very simple, just load an HTML code in the UIWebview and play it. The HTML code includes a tag to play the video file in the bundle. When testing it on iPhone, the video can play properly in a fullscreen mode (as default), but the Xcode console displays a long list of the error message:

UIWebviewVideoTest[22503:904174] Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)

(

 "<NSAutoresizingMaskLayoutConstraint:0x7f8df9da8ed0 h=-&- v=-&- _UIBackdropContentView:0x7f8dfc034370.width == _UIBackdropView:0x7f8df9c4ec70.width>",
"<NSLayoutConstraint:0x7f8df9d974e0 H:|-(14)-[UILabel:0x7f8df9c45b40'Slide your finger down to...']   (Names: '|':_UIBackdropContentView:0x7f8dfc034370 )>",
"<NSLayoutConstraint:0x7f8df9d96900 H:[UILabel:0x7f8df9c45b40'Slide your finger down to...']-(14)-|   (Names: '|':_UIBackdropContentView:0x7f8dfc034370 )>",
"<NSLayoutConstraint:0x7f8df9d835c0 H:|-(0)-[_UIBackdropView:0x7f8df9c4ec70]   (Names: '|':UIView:0x7f8df9c52bf0 )>",
"<NSLayoutConstraint:0x7f8df9d83610 H:[_UIBackdropView:0x7f8df9c4ec70]-(0)-|   (Names: '|':UIView:0x7f8df9c52bf0 )>",
"<NSLayoutConstraint:0x7f8df9d83910 H:|-(0)-[UIView:0x7f8df9c52bf0]   (Names: '|':AVAlphaUpdatingView:0x7f8df9c44190 )>",
"<NSLayoutConstraint:0x7f8df9d83960 H:[UIView:0x7f8df9c52bf0]-(0)-|   (Names: '|':AVAlphaUpdatingView:0x7f8df9c44190 )>",
"<NSLayoutConstraint:0x7f8df9daf950 'UIView-Encapsulated-Layout-Width' H:[AVAlphaUpdatingView:0x7f8df9c44190(0)]>"

)

Will attempt to recover by breaking the constraint

<NSLayoutConstraint:0x7f8df9d96900 H:[UILabel:0x7f8df9c45b40'Slide your finger down to...']-(14)-|   (Names: '|':_UIBackdropContentView:0x7f8dfc034370 )>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in may also be helpful.

When I test it on iPad, the inline play mode is OK, but when playing video in a fullscreen mode, a similar error was displayed in the console. It seems the error is associated with the fullscreen video play in a UIWebview. Does anyone know why this error message was generated and how to avoid it? Thanks!

lornova
  • 6,667
  • 9
  • 47
  • 74
Steve Wang
  • 794
  • 6
  • 19
  • 1
    There is no error message displayed when I test it in Xcode 6.3 and iOS 8 SDK with swift. – Steve Wang Sep 24 '15 at 15:21
  • Can you please provide what constraints you have added to the webView. And also how you have instantiated it. – Ishan Handa Sep 24 '15 at 20:05
  • I just added the top, bottom, leading and tailing constraints between the UIWebview and the root view to make a "margin" region. And there is only one subview (the UIWebview) in the root view. – Steve Wang Sep 24 '15 at 20:16
  • If the UIWebView was added programmatically make sure translatesAutoresizingMaskIntoConstraints is set to NO – Ishan Handa Sep 24 '15 at 20:55
  • The UIWebview and constraints were all added in storyboard. – Steve Wang Sep 24 '15 at 21:12
  • I'm having exactly the same issue and so far I'm unable to find answer. I suspect that iOS 9 needs fixing ... – kkazakov Sep 25 '15 at 10:23
  • I just tried to use the WKWebView instead of the UIWebView and the same error message was displayed in the Xcode console. – Steve Wang Sep 26 '15 at 21:01
  • I am experiencing the same error although I am using the AVPlayerViewController from within my UIViewController without a WebView. Looks like some of the constraints on the AVPlayerViewController are wrong in the iOS9 SDK. Can somebody second this ? – dehlen Sep 29 '15 at 19:58
  • @dehlen the same `Unable to simultaneously satisfy constraints` error happened to me when I wasn't passing a valid AVPlayer with a valid URL to the AVPlayerViewController – mash Oct 27 '15 at 05:48
  • I fixed it with this little hack here: http://stackoverflow.com/questions/32860362/unable-to-simultaneously-satisfy-constraints-warnings-with-avplayerviewcontrolle – dehlen Oct 27 '15 at 16:26
  • 1
    I am still facing same issue as of iOS 9.2. Anyone able to solve it ? – Raj Jan 19 '16 at 21:21
  • If for development we are using auto layout then even if any view added through code, we have to provide constraints for it in code as well. – aman.sood Feb 26 '16 at 14:27
  • Can you provide code to have better understandings – Albi Apr 13 '17 at 09:22

1 Answers1

1

It's an Apple bug.

Bug was fixed in newer iOS versions.

If you still experience it - file a bug report to Apple.

Andrei Konstantinov
  • 6,971
  • 4
  • 41
  • 57