Issue metadata
Sign in to add a comment
|
Android WebView WebSettings.setUserAgentString() ignored in some requests
Reported by
cernilov...@gmail.com,
Oct 17
|
||||||||||||||||||||
Issue descriptionSteps to reproduce the problem: 1. Set a custom user agent in multiple WebViews via webView.getSettings().setUserAgentString() 2. Load websites in the WebViews via webView.loadUrl() simultaneously. These websites also load multiple requests via JavaScript What is the expected behavior? The custom user agent provided to setUserAgentString() should be set for all requests. What went wrong? Some random requests still use the default user agent. This happens especially if there are multiple WebViews with multiple requests running inside them. The chance that the bug occurs gets lower if a debugger is attached or the requests are delayed via Thread.sleep(), so this has probably something to do with parallel requests and multithreading. This bug did not occur in previous WebView versions. Did this work before? Yes I believe this worked in the previous stable version, so probably 68.0.3440 Does this work in other browsers? N/A Chrome version: 69.0.3497.100 Channel: stable OS Version: 9 Flash Version:
,
Oct 17
,
Oct 18
,
Oct 18
@cernilovsky: Could you please elaborate above steps to reproduce. Please let us know how to set custom user agent. Sample apk and screencast on reproducing would help in further triaging. Thanks!
,
Oct 22
,
Oct 22
I've been working on it, please give me few days, it isn't so easy to reproduce as I thought. Thanks!
,
Oct 22
Thank you for providing more feedback. Adding the requester to the cc list. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Oct 24
Your device isn't running Android 9: the build ID in the screenshot starts with OPM8 which is Android 8.1, as the UA says. Do you control the sites you're loading here, or are they someone else's? Do you know if the sites use a service worker? (it's possible that service worker initiated requests aren't going to use the useragent because they aren't associated with a specific webview)
,
Oct 25
@torne: You are right, my bad, I got confused by my Pixel C having Android 8.1 and Pixel running Android 9. I have discovered the bug is caused by the following: 1. There must be multiple WebViews. If only one WebView loads the page the User-Agent shows correctly. 2. The websites inside these WebViews have to send custom messages to WebViews via JavaScript's window.location.href="...". WebViews intercept these messages via shouldOverrideUrlLoading(). 3. The websites load some other resources via AJAX, but I believe this can also affect non-XHR requests. In the attachment you can find some screenshots, the sample app's APK and source code with sample web source code. Regarding the sample app, all the important code can be found in MainActivity.kt. Note that the bug is random so the results may be different every time you run the app.
,
Oct 25
Thank you for providing more feedback. Adding the requester to the cc list. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Oct 25
Note: If you have trouble building the sample app, just delete the assets folder, it is not necessary for running the app.
,
Nov 30
I can't repro with your compiled APK. Tried ~5 times on my device with 70.0.3538.110 and ~5 times with 69.0.3497.100. Any ideas for an easier repro?
,
Dec 11
I was able to to reproduce it in Google Pixel C, Pixel 1 and Samsung Galaxy S9, but not in Sony Xperia XZ (all with newest Chrome and available Android). It seems the bug is hardware dependent. It took me 2 weeks to find the real cause and make this sample app + web so I got no ideas for an easier repro except trying a different device, e. g. one of those stated above.
,
Dec 11
Thank you for providing more feedback. Adding the requester to the cc list. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Dec 12
Thanks for the info. Test team: does anyone have bandwidth to try to repro on Pixel C and do a per-build bisect? Per-CL would also be great, if possible.
,
Dec 28
As per comment#9 bug is random and results will be different everytime we run the app so unable to find per-build bisect.Could anyone help in finding actual and expected behavior with repro steps. Thanks!
,
Dec 28
Bug is random on all the builds even on M68 so it gets difficult to find the per-build & per-cl bisect.Tried on M69 ,M70& M71 and while we try to clear the app, randomly it is happening .Please share the good& bad behaviour with a video.Thanks.
,
Dec 30
cernilovsky@ what is the expected repro rate for your test app on Pixel C?
,
Jan 2
It is near 100 %, see the video: https://photos.app.goo.gl/FWmNLD7ojuLgxmgQ7 As you can see in all three cases most WebViews incorrectly showed the default user agent instead of the custom one, in the second case the custom and default agents were mixed together.
,
Jan 2
Thank you for providing more feedback. Adding the requester to the cc list. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Jan 2
Given this has a very high repro rate, could testers try to bisect? Expected result: every WebView says "Custom user agent string" Buggy result: at least 1 WebView says "Mozilla 5.0... " etc. (the default user agent) Please let me know if we do not observe a very high repro rate as seen in the video.
,
Jan 10
#21 - We will try to bisect and update.
,
Jan 11
+alekyoo for help with bisect
,
Jan 14
https://chromium.googlesource.com/chromium/src/+log/69.0.3497.2..68.0.3440.134?pretty=fuller&n=10000 per CL bisect im having issues, still working on it. Will update later
,
Jan 14
^ That range looks suspicious. 69.0.3497.2 is (conventionally speaking) higher than 68.0.3440.134. Technically, there are some CLs in 68...134 that didn't make it in 69...2, but I would be surprised if our bisect script can actually identify such a range.
,
Jan 14
per build bisect: https://chromium.googlesource.com/chromium/src/+log/68.0.3440.134..69.0.3497.2?pretty=fuller&n=10000 per CL bisect: You are looking for a change made after 571542(GOOD), but before 571543(BAD). https://chromium.googlesource.com/chromium/src/+/afde76d6ab1d064821294da9d31cd626cbf8581a AND https://chromium.googlesource.com/chromium/src/+/afde76d6ab1d064821294da9d31cd626cbf8581a
,
Jan 14
,
Jan 14
,
Jan 15
New per build range: https://chromium.googlesource.com/chromium/src/+log/69.0.3475.4..69.0.3476.0?pretty=fuller&n=10000 per CL range is pointing to this: https://chromium.googlesource.com/chromium/src/+/8962649114490c145c5cba76fe290752014d6432 showing me this You are looking for a change made after 571042(GOOD), but before 571170(BAD). https://chromium.googlesource.com/chromium/src/+log/f90a0855264592f514c1dd8529460f01f5e93bf0..8962649114490c145c5cba76fe290752014d6432 all changes were made between good and bad builds
,
Jan 15
8962649114490c145c5cba76fe290752014d6432 is not a likely culprit. https://chromium.googlesource.com/chromium/src/+log/f90a0855264592f514c1dd8529460f01f5e93bf0..8962649114490c145c5cba76fe290752014d6432 is a bit narrower than the per-build range. aluo@ why can't the per-cl script narrow the range further? The script should *not* point to an individual CL if the range is wide (if the script does not have such output, perhaps we can improve the output to clarify what testers should post to the crbug). At this point, I'd rather see a trustworthy (and narrow) per-cl bisect range before we pass to devs for further investigation. If such a range is impossible, please explain and pass back to the bugcop queue. I'm passing to aluo@ to investigate why the script is acting up, and if we can get better results here.
,
Jan 15
All the builds used for the per-cl-bisect between 571042 and 571170 are missing, possibly due to the builds not compiling in that range or something went wrong with the builder that builds them, but I don't know since the old logs are gone. The tool prints out both good and bad builds in the case that the range contains more than 1 commit such as what happened here. alekyoo@, assigning back to you to make sure the range is correct though, let's chat tomorrow.
,
Jan 15
alekyoo@ confirmed that the repro is consistent on the good and bad builds.
,
Jan 15
|
|||||||||||||||||||||
►
Sign in to add a comment |
|||||||||||||||||||||
Comment 1 by cernilov...@gmail.com
, Oct 17