Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression(255659@main) Unable to log into twitch.tv #10760

Merged

Conversation

cdumez
Copy link
Contributor

@cdumez cdumez commented Feb 27, 2023

541ca5a

Regression(255659@main) Unable to log into twitch.tv
https://bugs.webkit.org/show_bug.cgi?id=253026
rdar://105891522

Reviewed by Wenson Hsieh and Darin Adler.

The Twitch.tv login was failing because `screen.orientation` was returning
"portrait-primary" on macOS. The natural/default orientation on desktop should
be "landscape-primary" so this was confusing Twitch.

Also update our `screen.angle` logic to take into account the natural
orientation based on:
- https://w3c.github.io/screen-orientation/#dfn-screen-orientation-values-table

I have verified that Chrome on macOS returns "landscape-primary" for the type
and 0 for the angle. Our behavior is now aligned.

* LayoutTests/fast/screen-orientation/natural-orientation-expected.txt: Added.
* LayoutTests/fast/screen-orientation/natural-orientation.html: Added.
* LayoutTests/platform/ios/screen-orientation/natural-orientation-expected.txt: Added.
* Source/WebCore/page/ScreenOrientation.cpp:
(WebCore::ScreenOrientation::lock):
* Source/WebCore/page/ScreenOrientationType.h:
(WebCore::naturalScreenOrientationType):
* Source/WebCore/platform/ScreenOrientationProvider.cpp:
(WebCore::ScreenOrientationProvider::currentOrientation):
* Source/WebKit/WebProcess/WebCoreSupport/WebScreenOrientationManager.cpp:
(WebKit::WebScreenOrientationManager::currentOrientation):

Canonical link: https://commits.webkit.org/260944@main

491d27d

Misc iOS, tvOS & watchOS macOS Linux Windows
βœ… πŸ§ͺ style βœ… πŸ›  ios βœ… πŸ›  mac   πŸ›  wpe   πŸ›  wincairo
βœ… πŸ§ͺ bindings βœ… πŸ›  ios-sim βœ… πŸ›  mac-AS-debug   πŸ›  gtk
βœ… πŸ§ͺ webkitperl   πŸ§ͺ ios-wk2   πŸ§ͺ api-mac   πŸ§ͺ gtk-wk2
  πŸ§ͺ api-ios   πŸ§ͺ mac-wk1   πŸ§ͺ api-gtk
  πŸ›  tv   πŸ§ͺ mac-wk2
  πŸ›  tv-sim   πŸ§ͺ mac-AS-debug-wk2
  πŸ›  watch   πŸ§ͺ mac-wk2-stress
❌ πŸ›  watch-sim
βœ… πŸ›  πŸ§ͺ unsafe-merge

@cdumez cdumez self-assigned this Feb 27, 2023
@cdumez cdumez added the WebCore Misc. For miscellaneous bugs in the WebCore framework (and not JavaScriptCore or WebKit). label Feb 27, 2023
Comment on lines +51 to +56
#if PLATFORM(IOS_FAMILY)
return ScreenOrientationType::PortraitPrimary;
#else
// On Desktop, the natural orientation must be landscape-primary.
return ScreenOrientationType::LandscapePrimary;
#endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For Apple platforms there are the following: iPhone, iPad, watchOS, tvOS, macOS. To me, it is obvious that iPhone is clearly portrait-primary. Not as clear that iPad, watchOS, and tvOS all should be.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We had this discussion a while back with Tim and Wenson. iPad apparently doesn't have a clear "natural" orientation so we had decided to stick with PortraitPrimary like iPhone.

For watchOS and tvOS, we didn't explicitly discuss it so I had lumped them all together. I don't think the screen orientation API is super relevant to these platforms. We may want to refine this at some point though.

For now at least, this patch is not changing behavior for these platforms. The behavior change is for macOS at this point, where we have a clear regression.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And presumably also changes behavior for all non-Apple platforms?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you wrote PLATFORM(IOS) it would be iPhone and iPad; that’s what I would do.

Copy link
Contributor Author

@cdumez cdumez Feb 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other platforms don't support this yet:

bool defaultShouldEnableScreenOrientationAPI()
{
#if PLATFORM(MAC)
    return true;
#elif PLATFORM(IOS_FAMILY)
    static bool shouldEnableScreenOrientationAPI = linkedOnOrAfterSDKWithBehavior(SDKAlignedBehavior::ScreenOrientationAPIEnabled);
    return shouldEnableScreenOrientationAPI;
#else
    return false;
#endif
}

So yes but it doesn't matter yet to them.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But why take the risk to change the behavior on Watch and TV on the branch at this point?

OK.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't mind changing behavior in a follow-up if people think TV and Watch should default to landscape (For TV I could see it make sense, for watch unsure). However, in this patch I'd rather focus on the macOS regression.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tv’s natural orientation should be landscape, if it even supports this API, but it’s not very important, not enough to change on a branch, certainly (but maybe on trunk).

For iPad, it seems the natural orientation is increasingly evolving to be landscape, but if it already was portrait, it doesn’t seem important to change it late in a release. (Maybe for a later release).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will follow-up for TV and iPad.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up: #10803

@cdumez cdumez force-pushed the 253026_screen_natural_orientation branch from 2b671ee to e75c0a2 Compare February 28, 2023 02:41
@cdumez cdumez force-pushed the 253026_screen_natural_orientation branch from e75c0a2 to 491d27d Compare February 28, 2023 16:18
@cdumez cdumez added the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Feb 28, 2023
https://bugs.webkit.org/show_bug.cgi?id=253026
rdar://105891522

Reviewed by Wenson Hsieh and Darin Adler.

The Twitch.tv login was failing because `screen.orientation` was returning
"portrait-primary" on macOS. The natural/default orientation on desktop should
be "landscape-primary" so this was confusing Twitch.

Also update our `screen.angle` logic to take into account the natural
orientation based on:
- https://w3c.github.io/screen-orientation/#dfn-screen-orientation-values-table

I have verified that Chrome on macOS returns "landscape-primary" for the type
and 0 for the angle. Our behavior is now aligned.

* LayoutTests/fast/screen-orientation/natural-orientation-expected.txt: Added.
* LayoutTests/fast/screen-orientation/natural-orientation.html: Added.
* LayoutTests/platform/ios/screen-orientation/natural-orientation-expected.txt: Added.
* Source/WebCore/page/ScreenOrientation.cpp:
(WebCore::ScreenOrientation::lock):
* Source/WebCore/page/ScreenOrientationType.h:
(WebCore::naturalScreenOrientationType):
* Source/WebCore/platform/ScreenOrientationProvider.cpp:
(WebCore::ScreenOrientationProvider::currentOrientation):
* Source/WebKit/WebProcess/WebCoreSupport/WebScreenOrientationManager.cpp:
(WebKit::WebScreenOrientationManager::currentOrientation):

Canonical link: https://commits.webkit.org/260944@main
@webkit-commit-queue
Copy link
Collaborator

Committed 260944@main (541ca5a): https://commits.webkit.org/260944@main

Reviewed commits have been landed. Closing PR #10760 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit 541ca5a into WebKit:main Feb 28, 2023
@webkit-commit-queue webkit-commit-queue removed the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Feb 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WebCore Misc. For miscellaneous bugs in the WebCore framework (and not JavaScriptCore or WebKit).
Projects
None yet
7 participants