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

fix broken copy, paste and showFindMode since Chrome 74 #3277

Merged
merged 5 commits into from
May 12, 2019

Conversation

gdh1995
Copy link
Contributor

@gdh1995 gdh1995 commented Mar 23, 2019

During tests I found that a setTimeout is needed, although I haven't found why.

This can fix #3260, fix #3292, fix #3297, fix #3298, fix #3302, fix #3307, fix #3311, fix #3313 and fix #3315 .

During tests I found that a setTImeout is needed.
@gdh1995 gdh1995 changed the title a try to fix broken hud.*** since Chrome 74 a try to fix broken hud.*** and FindMode since Chrome 74 Apr 15, 2019
@gdh1995
Copy link
Contributor Author

gdh1995 commented Apr 26, 2019

@smblott-github Would you like to merge this for just a try? There're quite a few issues reporting the new FindMode and clipboard issue on Chrome 74, and this PR works on my laptop and PC (both are Win 10 x64).

Update: I've confirmed the detailed reason of this breaking and this PR should work well on a very slow computer.

@riftEmber
Copy link

How did you divine the 17ms solution? (I haven't tested)

@gdh1995
Copy link
Contributor Author

gdh1995 commented Apr 27, 2019

How did you divine the 17ms solution? (I haven't tested)

I once thought it's the recently-added "user activation" logic (since Chrome 72) that prevents Vimium code from working. The "user activation" logic is designed to pass privileges across frames and remove them after a while. Therefore, if it has bugs, Chrome may mistakenly pass "disabled" status from a normal web page to Vimium's privileged frames, and then at a small time span code may fail.

So I tried adding a timeout and found the privilege came back. Recently, I noticed that "0ms" might be not enough, and "17ms" seems to work well - if not, we may increase it again.

But I navigated Chromium source code for minutes but didn't find any buggy source code. More survey is needed.

@gdh1995
Copy link
Contributor Author

gdh1995 commented Apr 27, 2019

Update: after more tests, I find it's a race condition:

  • the action of element.focus() / select() can work only if a document "is" visible
    • if a doc is not visible, getSelection().selectAllChildren() works but
    • the "visible selection" is none, and getSelection() + "" always returns "" (an empty string).
  • But in most time a HUD iframe has vimiumUIComponentHidden and its "display" is "none",
    • although Vimium code may call "toggleIframeElementClasses" for paste
    • it needs a tiny time span to spread the "display:block" style to the HUD frame.

Therefore, a toggleIframeElementClasses + getComputedStyle before postMessage can help a lot:

  • should call toggleIframeElementClasses before all 3 HUD actions: showFind, copy, paste
  • getComputedStyle is to enforce a style update immediately

But during tests in today there're about 1 / 10 cases where th HUD could not get focused, so I think the setTimeout 17 is still necessary.

@innaterebel
Copy link

Let's also try tagging @philc to see if he will sort things out. (if tagging the project owner is even necessary for him to get notified...)

@gdh1995
Copy link
Contributor Author

gdh1995 commented Apr 28, 2019

I've confirmed the comment I wrote above:

  • Chrome 74 refuses Element.focus and Selection.toString in an iframe if the iframe is not visible
  • Vimium's iframePort for HUD iframe is created by MessageChannel
  • changes to <iframe>.classList posts a new task and Chrome does style updates in the task
    • the task is not executed until the JavaScript code finishes and the task manager continues its task loop.
    • during the task, some messages are sent from parent frame (a content page) to child frame (HUD)
    • the message channel is IPC
    • one message is RenderWidget::OnWasShown and stack trace on HUD is:
      • RenderWidget::OnWasShown -> RenderWidget::SetHidden -> LayerTreeView::SetVisible
  • then there's a potential race condition between execCommand("Copy") and SetVisible
    • in fact, usually execCommand("Copy") is eariler if only HUD has been inited
    • while before Chrome 74 a hidden frame of display:none can still copy text
      • making us ignore the race condition.

Here's the result of chrome://tracing using Vimium master (v1.64.5) on Chrome 74.0.3729.108 x64 (blank User Data, Win 10):

image

The result of this PR:

image

@gdh1995 gdh1995 changed the title a try to fix broken hud.*** and FindMode since Chrome 74 fix broken copy, paste and showFindMode since Chrome 74 Apr 28, 2019
@mohitt
Copy link

mohitt commented Apr 30, 2019

Great tool :). But this bug, after update is causing huge pain. Please update the extension

@gdh1995
Copy link
Contributor Author

gdh1995 commented May 3, 2019

@smblott-github Sorry to disturb you again, but there have been so many issues reporting FindMode focusing and copying problem on Chrome 74. Would you have time to merge this? This PR has been verified carefully.

@funnydman
Copy link

Guys, please merge it if everything is okay because someone switched to the mouse again(

@athakral
Copy link

athakral commented May 7, 2019

If someone is in dublin, Ireland. May be he can request him personally.

https://www.computing.dcu.ie/~sblott/

@megalithic
Copy link

@smblott-github friend; this is huge! would love to have this merged in, to further make this tool amazing again! thanks!

@elongl
Copy link

elongl commented May 8, 2019

Why don't we merge this is it seems to work?
Also, isn't there a better solution than setting a timeout?

@gdh1995
Copy link
Contributor Author

gdh1995 commented May 8, 2019

@elongl The timeout is just in case that a computer might be too slow, and won't generate appreciable delay, so I think it should be here (The delay of loading Vomnibar is mostly from common HTML webpage loading and painting).

@elongl
Copy link

elongl commented May 8, 2019 via email

@adriangonzalez
Copy link

For anyone that's getting a little jumpy on this issue, it looks like a fix is coming, but in the meantime, cmd/ctrl+F still works ;)

@innaterebel
Copy link

Hate to break it to you guys, but do you know the word "abandoned"? That's where we indeterminately are.

While everybody is welcomed to make pull requests in an open source project, a project does have an owner and owner-approved committers, who are the only people possessing the privilege to actually merge a pull request and publish an official build.
For Vimium, the owner is @philc, and currently the only committer is @smblott-github. Unfortunately, both of them have been inactive for quite some time for reasons unknown, so the practically abandoned state we are in.

The abandonment is likely not intentional, but there is no guarantee the two will come back. If you are really bothered by the issues and cannot wait around it, you may want to find an alternative extension.

@gdh1995
Copy link
Contributor Author

gdh1995 commented May 9, 2019

@mrmr1993 Sorry to disturb you but do you still have committing permission to Vimium repo? I'd like this PR to be merged to fix Vimium's FindMode focus and clipboard operations issues, which occur on Chrome 74 and are quite annoying.

@mrmr1993
Copy link
Contributor

mrmr1993 commented May 9, 2019

@gdh1995 never had commit permissions. I left a query comment on the code, but nothing I can do on actually merging, sorry.

@ssangervasi
Copy link

innaterebel was a bit sassy, but it is likely the maintainers have lost interest. The good thing about open source is that we can fork it and even release a fork to the extension store. In fact, gdh1995 has a fork/rewrite. I appreciate their efforts to fix the original project, and I'm curious how stable Vimium-C is.

@gdh1995
Copy link
Contributor Author

gdh1995 commented May 10, 2019 via email

@doingnothing
Copy link

Could you help me?
Failed to load extension
File
~/Downloads/vimium-fix-focus-of-hud
Error
Could not load background script 'lib/utils.js'.
Could not load manifest.

@gdh1995
Copy link
Contributor Author

gdh1995 commented May 10, 2019

vimium_1.64.5-merge-3277.zip

@doingnothing This is my compiled version of this PR.

If you want to use Vimium from source code, then you need to "compile" Vimium, and you need to install Node.js, CoffeeScript, and run cake build. Refer: https://github.com/philc/vimium/blob/master/CONTRIBUTING.md#installing-from-source

@doingnothing
Copy link

vimium_1.64.5-merge-3277.zip

@doingnothing This is my compiled version of this PR.

If you want to use Vimium from source code, then you need to "compile" Vimium, and you need to install Node.js, CoffeeScript, and run cake build. Refer: https://github.com/philc/vimium/blob/master/CONTRIBUTING.md#installing-from-source

I just found your extension on Chrome Web Store.
https://chrome.google.com/webstore/detail/vimium-c/hfjbmagddngcpeloejdejnfgbamkjaeg?hl=en-US
And successfully installed it.
It seems to work perfectly.
Thank you very much!

@elongl
Copy link

elongl commented May 10, 2019

@gdh1995
Should I replace my Vimium with your Vimium C?
Would you keep maintaining it?

@gdh1995
Copy link
Contributor Author

gdh1995 commented May 10, 2019 via email

@innaterebel
Copy link

innaterebel commented May 10, 2019

So why doesn't someone else fork the project and just basically take ownership of it?

So why did you ask this when there has always been one and is mentioned in this thread (and many other places in this issue tracker)...

Someone who actually cares about Vimium.

Don't get me wrong, I fully appreciate all developers who has been participated in this project for their honorably wasting of their time. I was not complaining about them for anything.
I am not a native speaker, not familiar with the actual impression and extra nuance a word may imply to the native speaker, some unintentional strong words may be used. I may sound sarcastic or something, if any, is not toward the developers.
I just wanted to explain the actually long-standing circumstance as more and more people could not see it.

It is less than obvious to people who are new to Vimium (moreover, new to this repository pages), but the developing power of Vimium is in fact currently in its lowest, since just before Firefox officially dropped the support of their versatile legacy add-ons, which introduced a whole lot of demand to the simplism Vimium.
With the departure of the last contributors, and the remain only committer apparently ran out his time or motivation to do major updates to the project. In the past couple months the only thing that was gain is the kind and helpful gdh1995.

I filed this focus/copy issue one month before it reached the stable version of Chrome, worrying the only committer would go completely offline anytime soon (the owner has been almost offline for years), but it was still too late.
It's a pity the developers gone without saying hi, but that's about it, the nature of open source volunteering, again not blaming any of them. We don't know any fact about their missing after all. The only thing we can know through a few clicks in this repository is the stressful demand to the project. If you are unaware, this is the story.

@philc
Copy link
Owner

philc commented May 11, 2019 via email

pages/hud.coffee Outdated Show resolved Hide resolved
@athakral
Copy link

Ye ye he is back :)

@philc philc merged commit 1539f47 into philc:master May 12, 2019
@philc
Copy link
Owner

philc commented May 12, 2019

@gdh1995 great work on this. This problem was tricky and the fix is thoroughly researched and explained. I'll merge and cut a new release.

@philc
Copy link
Owner

philc commented May 12, 2019

This is now on the chrome store as v1.64.6 and should roll out in the next few hours.

@gdh1995 gdh1995 deleted the fix-focus-of-hud branch May 12, 2019 07:41
@adriangonzalez
Copy link

adriangonzalez commented May 13, 2019

/ is working for find, but n-Next and p-Previous aren't working for me?

@adriangonzalez
Copy link

Working now.

@gdh1995
Copy link
Contributor Author

gdh1995 commented Jun 16, 2019

For who are interested in the browser code behind, here's what I find in the source code of Chromium:

https://github.com/gdh1995/vimium-c/blob/419e0c3067606f32f94779326de60f84ddbbf507/types/vimium_c.d.ts#L784-L801

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment