delight-im / Android-AdvancedWebView

Enhanced WebView component for Android that works as intended out of the box
MIT License
2.39k stars 574 forks source link

Desktop mode doesn't work on some sites #127

Closed casolorz closed 7 years ago

casolorz commented 7 years ago

I tried desktop mode on this site http://alltube.tv/ and it still loaded the mobile site. Chrome however loaded the desktop site. I'm wondering if there is anything else that can be done?

Thanks.

ocram commented 7 years ago

Thanks!

Could you please point both Chrome and your WebView (in desktop mode) to

https://httpbin.org/user-agent

so that we can see what user-agent string they're actually using?

casolorz commented 7 years ago

AdvancedWebView: { "user-agent": "Mozilla/5.0 (Linux; diordnA 7.1.1; Nexus 6 Build/N6F26U; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/57.0.2987.132 eliboM Safari/537.36" }

Chrome: { "user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.132 Safari/537.36" }

However I have tried using the Chrome user agent with that site. The issue I think is a little deeper, probably viewport or something.

ocram commented 7 years ago

Unfortunately, I can't really see why this isn't working as expected.

In general, any site may, of course, implement their own detection for mobile user agents, so the Nexus string might have been added to the list of keywords known to be from mobile here.

Thus, after your call to

myWebView.setDesktopMode(true);

could you please add

myWebView.getSettings().setUserAgentString("Mozilla/5.0 (Linux; diordnA 7.1.1; suxeN 6 Build/N6F26U; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/57.0.2987.132 eliboM Safari/537.36");

and see if that changes anything? Otherwise

myWebView.getSettings().setUserAgentString("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.132 Safari/537.36");

might be a last resort, which is just your current user-agent string from Chrome.

ocram commented 7 years ago

Well, given that you tried the Chrome string already, neither of those two lines will probably help. Sorry!

But right now, I don't see any other quick solution. The viewport should be set correctly.

casolorz commented 7 years ago

Yeah I think the site is doing some other check that chrome is getting right. Might be the screen size or something. Thanks for checking.

ocram commented 7 years ago

No problem!

But shouldn't the screen size be identical? I assumed you were testing Chrome and the WebView on the same device.

Apart from that, the viewport should be correct as well since we change it here.

Since the desktop mode seems to work on most popular sites, I would rather say the detection done by this site is obscure and fails here. But that doesn't help you, of course.

Closing for now, until we have any new insights.

casolorz commented 7 years ago

Yes I'm going on the same device. If I go to http://www.alanwood.net/demos/browserinfo.html with chrome with and without desktop mode, I get two different sizes for the last of the sizes. No idea if that is what they are detecting.

Anyways, I agree that this is probably just a weird implementation on that site.