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

Chrome v59 on Windows detects touchOnly on desktop #8

Closed
pnarielwala opened this issue Jun 28, 2017 · 39 comments
Closed

Chrome v59 on Windows detects touchOnly on desktop #8

pnarielwala opened this issue Jun 28, 2017 · 39 comments

Comments

@pnarielwala
Copy link

Hey Rafael,

Just wanted to bring it to your attention that now Chrome v59 on windows doesn't correctly detect mouse (and mistakes it for touchOnly device) in addition to Firefox. Seems to only happen on Windows and Macs are fine

@rafgraph
Copy link
Owner

Thanks for reporting. Much appreciated. I'm able to reproduce the Chrome v59 error on Windows, but Firefox v54 reads as hybrid not touch-only for me because of what we discussed in #4. Does Firefox read as touch-only for you?

@rafgraph
Copy link
Owner

@pnarielwala are you on a mouse only or hybrid windows machine?

@rafgraph
Copy link
Owner

@RByers it looks like Chrome v59 on Windows is giving a weird response to the hover and pointer media queries. I'm on a Windows 10 hybrid (primarily a mouse device) hover and any-hover are false, and pointer fine and any-fine are also false. See this detection test. Is there a reason for this? Is this a bug? Thanks.

@pnarielwala
Copy link
Author

@RAFREX I am on a mouse only windows machine

@pnarielwala
Copy link
Author

And mozilla now reads as hybrid which is fine, but maybe browsers are moving towards not supporting window.matchMedia()?

@pnarielwala
Copy link
Author

Maybe we could use window.navigator.userAgent instead?

@rafgraph
Copy link
Owner

I don't think browsers are not going to support window.matchMedia(), as that would break many responsive websites (Firefox supports window.matchMedia), it is just the hover and pointer media queries that are in question (Firefox never supported them). Chrome used to support them, and I'm guessing this is a bug, because the hover none and pointer coarse MQs a true on my hybrid, but hopefully @RByers can shed some light on this for us. It would be shame if Chrome stopped supporting them, unless they have a better replacement.

I'd prefer to only use userAgent as a last resort to patch holes and bugs, like this one. I'd be happy to accept a PR using userAgent as a targeted fix for this issue if you have time to work on it.

@pnarielwala
Copy link
Author

So just checked this morning, and Chrome seemed to have fixed itself! I'll monitor it throughout the day and then close this issue

@RByers
Copy link

RByers commented Jul 10, 2017

Sorry for the delay. @darktears made some improvements in Chrome 59 on Windows here to try to better handle the convertible case. I.e. when in tablet mode we expect touch to be primary. But we rely on the OS to tell us when it's in tablet mode, so maybe that's not 100% reliable? Or perhaps we have some other issue? /cc @mustaqahmed.

@darktears
Copy link

I've tested intensively with as much detachable and convertible devices I could get around me. However it seems like one scenario is not working. I'm still troubleshooting it as we speak https://bugs.chromium.org/p/chromium/issues/detail?id=739430

@rafgraph
Copy link
Owner

Great, thanks for the info. I'm on vacation until next week and will look into it more then.

@darktears
Copy link

I just landed https://chromium.googlesource.com/chromium/src.git/+/6edbb267b6d43303d08e758ff63f941df5c8ff7f

Can someone try a Canary build in the coming days and confirm it works fine. Then I can ask the patch to be backported in other branches.

@rafgraph
Copy link
Owner

@darktears I just tested it with Canary (v62.0.3164.0) on an ASUS TP200S (with Windows 10) and it is not working (hover and any-hover MQs never match). This is a non-detachable hybrid that can enter tablet mode, but regardless of if it is in tablet mode or not, the hover and pointer MQs don't reflect that it has a mouse input device.

Note that on this device, even when it is in tablet mode, the mouse still works. Maybe if the device is a non-detachable hybrid, then the any-hover and any-fine MQs should always match?

@darktears
Copy link

darktears commented Jul 25, 2017

@RAFREX provided it is this model https://www.asus.com/us/2-in-1-PCs/ASUS_Transformer_Book_Flip_TP200SA/ it's a convertible laptop? So it should supports screen rotation and CONVERTIBLESLATEMODE should be supported in the registry. I'm puzzled why your laptop was buggy in the first place. The issue I fixed here was about touch screen laptops only (not hybrid).

What does https://googlechrome.github.io/samples/media-hover-pointer/ says?

@rafgraph
Copy link
Owner

rafgraph commented Jul 27, 2017

@darktears yea that's the one I have. I tried your link, but got the same results (see picture). The pointer and hover media queries were working fine as of Chrome v58.

I'm not much with PCs (just have this one for testing purposes), but I'm happy to check something on it for you.

image

@rafgraph
Copy link
Owner

@pnarielwala is it working fine for you on your mouse only machine? Are you able to test it out on other PCs/hybrids? Thanks.

@darktears
Copy link

@RAFREX I can't access the hardware so I will make an experimental build of Chromium with some debug output so you can give me more infos.

@darktears
Copy link

darktears commented Jul 28, 2017

Hi @RAFREX,

Can you try this build : https://drive.google.com/open?id=0B65HPC3GJ5tEWTNzMmpiWlRjMmM

Unzip it, run chrome.exe from the terminal (say git bash) with --enable-logging --v=0 as parameters. Access https://googlechrome.github.io/samples/media-hover-pointer/ and tell me what is the debug output in the terminal.

Thanks.

@darktears
Copy link

@RAFREX : did you had time to check it out?

@rafgraph
Copy link
Owner

rafgraph commented Aug 7, 2017

@darktears sorry been really busy, hopefully will get to it today.

Also, I have a friend with a ASUS Zenbook Pro UX501VW and it has the same issue. Don't know if you're able to access any ASUS convertible hardware, but might be worth a test if you can.

@darktears
Copy link

darktears commented Aug 10, 2017

I managed to grab an old ASUS T-100 and it behaves as expected. I really need the debug outputs to fix it further. I don't have access to any other ASUS laptops....

@rafgraph
Copy link
Owner

@darktears sorry for the delay on this and thanks for working to fix this issue.

I downloaded the debug build, unziped it, and ran it from git bash after cding into its directory:
$ start chrome --enable-logging --v=0
Two windows opened, one being the Chrome browser, and the other presumably the log (window with black background and flashing white cursor). However, nothing appeared in the log or in the gitbash terminal after navigating to https://googlechrome.github.io/samples/media-hover-pointer/ or any other site. What am I doing wrong? Sorry I'm not much of a Windows person.

Also of note, the debug build has the correct pointer and hover media query results. Where as canary still has the incorrect results. Not sure if this was intentional.

@darktears
Copy link

@RAFREX well you should see some debug output.

I'm puzzled about the fact you say the debug build returns the correct values. The debug build I sent you is basically master of Chromium with just few debug output, no functionality or behavior has been changed. Could you make sure your Canary is updated by going into the menu -> Help -> about Google Chrome.

@rafgraph
Copy link
Owner

@darktears yes it's up to date.
The canary version is: 62.0.3182.0
The dev build version is: 62.0.3170. 0

@darktears
Copy link

darktears commented Aug 11, 2017

@RAFREX there is no difference between the debug build I gave you and the canary build in term of code related to interaction MQs so I don't understand here why you're seeing two different outputs. Are you sure Canary doesn't trick you with caching or something?

Concerning the debug output could you check with cmd then chrome.exe --enable-logging --v=0. You have to see debug output because I'm debugging every single code path to detect the input type.

@rafgraph
Copy link
Owner

@darktears I clean canary's cache, no change. Tried launching the dev build with the added .exe extension, but no log shows up. I'm not sure what's up. Are there any build steps that are added or are different between the dev build and canary build?

@darktears
Copy link

darktears commented Aug 14, 2017

Absolutely no difference (beside the branding) so I'm really puzzled here really. @RByers do you have a clue of what's going on here?

@rafgraph
Copy link
Owner

rafgraph commented Aug 15, 2017

@pnarielwala I patched this with a userAgent detection. Can you let me know what the full read out is in chrome (including all subsections) from http://detect-it.rafrex.com on your windows mouse only device? Thanks.

@darktears
Copy link

darktears commented Aug 18, 2017

@RAFREX ok I figure out the differences. It was my bad when adding the debug stuff. Can you try https://drive.google.com/open?id=0B65HPC3GJ5tESFkwYzNBa3lXRjg again and tell me the debug output. You should see some for sure.

@rafgraph
Copy link
Owner

@darktears here's the debug output. Also, the new dev build hover and pointer media queries match canary (i.e. are incorrect).

[1820:7164:0821/140830.292:ERROR:win_util.cc(450)] ----Testing pointer devices----
[1820:7164:0821/140830.323:ERROR:win_util.cc(452)] GetPointerDevices 1
[1820:7164:0821/140830.323:ERROR:win_util.cc(465)] ----Testing touch screen----
[1820:7164:0821/140830.323:ERROR:win_util.cc(475)] ----Testing docked state----
[1820:7164:0821/140830.323:ERROR:win_util.cc(494)] ----Testing rotation support----
[1820:7164:0821/140830.323:ERROR:win_util.cc(507)] ----Testing platform role and SM_CONVERTIBLESLATEMODE----
[1820:7164:0821/140830.401:ERROR:win_util.cc(533)] !GetSystemMetrics(SM_CONVERTIBLESLATEMODE) :1
[1820:7164:0821/141042.371:ERROR:win_util.cc(450)] ----Testing pointer devices----
[1820:7164:0821/141141.954:ERROR:win_util.cc(452)] GetPointerDevices 1
[1820:7164:0821/141141.970:ERROR:win_util.cc(465)] ----Testing touch screen----
[1820:7164:0821/141141.970:ERROR:win_util.cc(475)] ----Testing docked state----
[1820:7164:0821/141141.970:ERROR:win_util.cc(494)] ----Testing rotation support----
[1820:7164:0821/141141.970:ERROR:win_util.cc(507)] ----Testing platform role and SM_CONVERTIBLESLATEMODE----
[1820:7164:0821/141141.970:ERROR:win_util.cc(533)] !GetSystemMetrics(SM_CONVERTIBLESLATEMODE) :1
[1820:7164:0821/141141.970:ERROR:win_util.cc(450)] ----Testing pointer devices----
[1820:7164:0821/141141.970:ERROR:win_util.cc(452)] GetPointerDevices 1
[1820:7164:0821/141141.985:ERROR:win_util.cc(465)] ----Testing touch screen----
[1820:7164:0821/141141.985:ERROR:win_util.cc(475)] ----Testing docked state----
[1820:7164:0821/141141.985:ERROR:win_util.cc(494)] ----Testing rotation support----
[1820:7164:0821/141142.001:ERROR:win_util.cc(507)] ----Testing platform role and SM_CONVERTIBLESLATEMODE----
[1820:7164:0821/141142.001:ERROR:win_util.cc(533)] !GetSystemMetrics(SM_CONVERTIBLESLATEMODE) :1
[1820:7164:0821/141142.001:ERROR:touch_device_win.cc(43)] IS TABLET PlatformRoleMobile

@pnarielwala
Copy link
Author

@RAFREX sure this is what I am getting on my mouse-only computer (although the sub sections do change sometimes upon restarting my computer)
detectit

@rafgraph
Copy link
Owner

@pnarielwala thanks. What's the model of your mouse-only computer? And what chrome version? This might be helpful for the Chromium team as the media query and touch event results are not what they should be.

@darktears it looks like a mouse-only windows device is also giving incorrect hover and point media query results (they reflect a touch only device, see the subsections in @pnarielwala screenshot above).

@RByers, @darktears it also seems like 'ontouchstart' in window is true for mouse-only windows device. Is this an intentional change? I'd much prefer it to remain false unless the device has a touch screen (which I thought was the consensus https://lists.w3.org/Archives/Public/public-touchevents/2016Dec/0007.html).

Note that Detect Touch Events hasSupport uses 'ontouchstart' in window, while browserSupportsApi uses Boolean(window.TouchEvent).

@pnarielwala
Copy link
Author

@RAFREX I'm on a Lenovo T440s with Chrome Version 60.0.3112.101 (Official Build) (64-bit)

@darktears
Copy link

darktears commented Aug 21, 2017

Stable Chrome 60 doesn't have the fix mentioned above so @pnarielwala result seems consistent. I suggest @pnarielwala tests Canary to verify the fix.

@RAFREX : Could you make sure you installed the latest ATK from Asus on https://www.asus.com/us/2-in-1-PCs/ASUS_Transformer_Book_Flip_TP200SA/HelpDesk_Download/. Restart after install.

@rafgraph
Copy link
Owner

@darktears I installed the latest ATK and restarted. No change in the media query results. Also the debug output looks the same as before (I can paste it if you want).

@pnarielwala can you post the same screen grab as before but using Chrome Canary? Thanks.

@darktears
Copy link

@RAFREX based on the debug this is not Chrome's fault. We use https://msdn.microsoft.com/en-us/library/windows/desktop/ms724385(v=vs.85).aspx GetSystemMetrics asking SM_CONVERTIBLESLATEMODE and your laptop returns that it's in slate mode (aka screen flipped and keyboard/trackpad disabled) when it's not. This is the last API we can use to detect if your laptop is a convertible. Previous tests are returning true for your hardware : it has a touch screen, it's not docked, and it supports rotation.

So here is my question : when you flip over the screen does Windows 10 ask you if you want to switch to tablet mode (without user interaction)? You should see a popup close to the time in the taskbar, e.g. https://onmessages.files.wordpress.com/2016/02/image001.png (make sure that in the settings you want to be asked about it https://www.cybernetman.com/files/siteContent/editor/Pics/KB380/Settings.png).

@RByers
Copy link

RByers commented Aug 24, 2017

@RByers, @darktears it also seems like 'ontouchstart' in window is true for mouse-only windows device. Is this an intentional change? I'd much prefer it to remain false unless the device has a touch screen (which I thought was the consensus https://lists.w3.org/Archives/Public/public-touchevents/2016Dec/0007.html).

That should be true only when Windows reports there is a touchscreen present. There are a number of known situations where Windows will lie and claim there is a touchscreen when there is not (like when you have installed Visual Studio and it's fake touchscreen driver used to simulating a touch screen).

@rafgraph
Copy link
Owner

rafgraph commented Dec 4, 2017

@darktears I don't have that Asus TP200S anymore, but I recall that it didn't ask me if I wanted to enter tablet mode, even though in the settings I had indicated such. Which I agree indicates there is something wrong on Asus's end.

My friend's Asus Zenbook Pro UX501VW started indicating the correct media query results in v62 (was only affected v59 - v61), so whatever you did in v62 helped. Also my new PC, a Lenovo Ideapad Flex 4 has the correct media query results.

For the Lenovo Ideapad, when I switch from computer mode to tablet mode and refresh the page the media queries change as expected, but when I switch back from tablet mode to computer mode the media query results continue to indicate a touch only device after page refresh. I have to close and restart Chrome to get the correct media query results. Just some feedback for something to look into.

As a side note, I'm not surprised that it's not Chrome's fault. Like a lot of frontend code I write it's not my fault all browsers don't implement things according to spec, but it's my responsibility to workaround browser deficiencies so my apps work. Just as I think it is Chrome's responsibility to work around computer deficiencies so that it works correctly.

@rafgraph
Copy link
Owner

rafgraph commented Dec 4, 2017

I'm going to close this issue and limit the workaround for detect-it to Windows Chrome v59 through v61.

@rafgraph rafgraph closed this as completed Dec 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants