WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
NEW
226025
document and window does not initially have focus in WKWebView
https://bugs.webkit.org/show_bug.cgi?id=226025
Summary
document and window does not initially have focus in WKWebView
raon0211
Reported
2021-05-20 09:20:40 PDT
Created
attachment 429179
[details]
videos that show the difference between mobile safari and wkwebview When loading webpages in WKWebView, document and window does not have initial focus. (`document.hasFocus()` returns `false` initially.) After receiving some user interactions such as touch, the `window`'s focus event fires and `document.hasFocus()` starts to return `true`. This is strange since in Mobile Safari, `document` and `window` have focus from the beginning. Since JavaScript libraries such as SWR or React Query revalidates the AJAX requests on window's focus events, this leads to extra XHR requests to fire when accessing sites using such libraries. The videos in the attached ZIP file below show the difference of Mobile Safari and WKWebView: In Mobile Safari, `document` and `window` immediately have focus. In WKWebView (Facebook In-app Web Browser), `document` and `window` does not have focus until user touch. The test page used in the video is
https://service-alpha.toss.im/test/focus-test
. --- Thread in WebKit slack:
https://webkit.slack.com/archives/CU5LWFM28/p1621516267010100
Attachments
videos that show the difference between mobile safari and wkwebview
(1.14 MB, application/zip)
2021-05-20 09:20 PDT
,
raon0211
no flags
Details
View All
Add attachment
proposed patch, testcase, etc.
raon0211
Comment 1
2021-05-20 09:21:46 PDT
The issue remains in many in-app browsers implemented with WKWebView.
Radar WebKit Bug Importer
Comment 2
2021-05-27 09:21:18 PDT
<
rdar://problem/78571876
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug