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

search function gets executed twice when loading ?search=foo page #90454

Closed
jsha opened this issue Oct 31, 2021 · 2 comments
Closed

search function gets executed twice when loading ?search=foo page #90454

jsha opened this issue Oct 31, 2021 · 2 comments
Assignees
Labels
A-rustdoc-ui Area: Rustdoc UI (generated HTML) C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@jsha
Copy link
Contributor

jsha commented Oct 31, 2021

Steps to reproduce:

  1. Visit https://doc.rust-lang.org/nightly/std/string/trait.ToString.html?search=foo
  2. In Chrome Developer Tools, select Sources > search1.58.0.js
  3. Use the { } in the lower right of that panel to pretty-print
  4. Use search to find function search().
  5. Add a breakpoint by clicking the line number to the left of the function>
  6. Reload the page.
  7. Hit F8 (resume script execution) as many times as necessary for the page to finish loading.

Expected result: Hit F8 only once.

Actual result: Hit F8 twice.

This is relevant because search is a CPU-intensive operation and blocks the UI thread. Doing it twice is a bad user experience.

This is a category of bug we've had at least once before. Rather the fix it by repairing the specific sequence of events that causes it, perhaps we should do some sort of memoization so that if search() is called for an input that is already displayed on the page, we don't actually execute the search again.

/cc @GuillaumeGomez

@jsha jsha added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. A-rustdoc-ui Area: Rustdoc UI (generated HTML) labels Oct 31, 2021
@jsha jsha added the C-bug Category: This is a bug. label Oct 31, 2021
@GuillaumeGomez
Copy link
Member

Thanks for adding the extra explanations for others! :)

@GuillaumeGomez
Copy link
Member

I double-checked locally and the execSearch function is only called once but the search function is called twice, which means that the "big" computation part is only run once as expected. So this issue can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustdoc-ui Area: Rustdoc UI (generated HTML) C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants