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

rustdoc: Source code pages briefly render in other font and weight as page loads #91374

Open
camelid opened this issue Nov 29, 2021 · 11 comments
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

@camelid
Copy link
Member

camelid commented Nov 29, 2021

For example: https://doc.rust-lang.org/nightly/nightly-rustc/src/rustc_attr/builtin.rs.html#96-99

This happens in macOS Safari. It doesn't seem to occur in Firefox on macOS.

I think this regressed within the last day or two since I would've noticed otherwise.

@camelid camelid added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. C-bug Category: This is a bug. A-rustdoc-ui Area: Rustdoc UI (generated HTML) labels Nov 29, 2021
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Nov 29, 2021
@camelid
Copy link
Member Author

camelid commented Nov 29, 2021

While the brief rendering in bold doesn't happen for the std docs—so I assume it's related to go-to-definition—the std docs do have a brief rendering in a different font that doesn't happen on beta, so I think the same issue is present there as well.

@camelid camelid changed the title rustdoc: Source code pages briefly render in bold as page loads rustdoc: Source code pages briefly render in other font and weight as page loads Nov 29, 2021
@camelid
Copy link
Member Author

camelid commented Jan 22, 2022

The flash-of-bold-text part seems to be fixed, but now the Rust logo flashes briefly in the sidebar while the page loads. cc @GuillaumeGomez

@camelid camelid removed the regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. label Jan 22, 2022
@camelid
Copy link
Member Author

camelid commented Jan 22, 2022

I'm removing the regression label because that nightly is long past and I don't know when the new regression occurred.

@camelid camelid removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Jan 22, 2022
@GuillaumeGomez
Copy link
Member

I'm not sure why it's flashing like this. Since @jsha worked on the font to prevent the flashing they might have an idea on what's wrong in here?

@jsha
Copy link
Contributor

jsha commented Jan 22, 2022

Here's my first trick in debugging such things: open the Dev Tools, go to Sources, and hit the "Pause" button, so the next execution of JS on the page will pause. Load the page. When JS execution is paused, you'll see that the logo is visible (but squashed) in the sidebar. That means the logo is shown by default, but hidden with JavaScript. That will cause a flash of visibility because the JS executes after the page loads. The solution will be to hide it with CSS instead.

In general I think we should overhaul both the design and the implementation of the source sidebar. Right now it's nestled inside the regular sidebar in the DOM, which makes styling it weird. It should really have its own <nav> element that can be styled independently. A couple of other source sidebar problems:

  • If you have the source sidebar expanded, when you navigate between pages, it re-does its "expand" animation. It should just start out expanded, with no animation.
  • While it's doing its expand animation, the Rust logo is squashed horizontally, and grows with the sidebar.

My preferred fix for these is to remove the animation. We don't do an animation like that for the mobile sidebar, and I don't think it adds much benefit.

@GuillaumeGomez
Copy link
Member

Removing animations sounds like a good idea. Less CSS to maintain. I'll try to put something together shortly.

@jsha
Copy link
Contributor

jsha commented Jan 22, 2022

Looks like maybe I was wrong about JS being the cause. We have this CSS rule:

.source .sidebar>*:not(:first-child) {
    transition: opacity 0.5s,visibility 0.2s;
    opacity: 0;
    visibility: hidden;
}

I think it's that visibility: 0.2s that's doing it. Basically our CSS is telling the page "this should be visibility: hidden, but take 200ms to make it so".

So I suspect removing the animations will fix the logo problem as well.

@GuillaumeGomez
Copy link
Member

Yes, it's what I just saw. This issue should be pretty easy to fix.

@camelid
Copy link
Member Author

camelid commented Jan 22, 2022

If you have the source sidebar expanded, when you navigate between pages, it re-does its "expand" animation. It should just start out expanded, with no animation.

I'd personally prefer that we just make the sidebar collapse upon navigating to a new page. I find it unintuitive that it stays open, and every time I navigate, I have to close it manually because it covers the page.

@jsha
Copy link
Contributor

jsha commented Jan 22, 2022 via email

@camelid
Copy link
Member Author

camelid commented Jan 22, 2022

Oops, I forgot that part is fixed. In that case, it still shrinks the rest of the page and adds noise.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 24, 2022
…, r=jsha

Fix brief appearance of rust logo in the sidebar

Part of rust-lang#91374.

I simply removed the CSS animation on the visibility, which now makes it all appear at once. I didn't change the CSS animation on the width though, which gives:

https://user-images.githubusercontent.com/3050060/150689595-067a6e00-9875-40c8-9d8a-1e3031dbcaba.mp4

cc `@camelid`

r? `@jsha`
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

4 participants