brave / brave-browser

Brave browser for Android, iOS, Linux, macOS, Windows.
https://brave.com
Mozilla Public License 2.0
17.57k stars 2.28k forks source link

Website layout render bug with 100% html & body height #40255

Open DrWarpMan opened 1 month ago

DrWarpMan commented 1 month ago

Description

When you use 100% html and body height, Brave incorrectly renders website, until you manually scroll the website.

html, body {
  height: 100%;
}

Steps to reproduce

  1. Create a simple index.html with the following content:

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <style>
      * {
        margin: 0;
        padding: 0;
      }
    
      html, body {
        height: 100%;
        background: linear-gradient(180deg, black 0%, red 100%);
      }
    
      body {
        display: flex;
        justify-content: center;
        align-items: center;
      }
    
      h1 {
        color: white;
      }
    </style>
    </head>
    
    <body>
    <h1>Foobar</h1> 
    </body>
    </html>
  2. Open the file in your Brave browser on your phone (either open locally or host on a server if available).
  3. The website should be rendered incorrectly. You should see that the text "Foobar" is not in the middle. Scroll up/down with your fingers & the layout will get adjusted to it's correct state. Both "Foobar" text and the gradient background will change position.

See the attached video below for visual explanation.

Actual result

Website is rendered incorrectly, with a "shifted layout".

https://github.com/user-attachments/assets/4feb0992-ae9f-4211-9626-efc52a3690c1

Expected result

Website should be rendered normally, without any "layout shifting". Like this: expected

Reproduces how often

Easily reproduced

Brave version

Brave 1.68.128, Chromium 127.0.6533.73

Device

(Tested on 2 different Android devices, both return the same result.)

Channel information

Reproducibility

Miscellaneous information

<!DOCTYPE html>
<html lang="en">
  <head>
    <style>
      html, body {
        height: 100%;
        background: linear-gradient(180deg, #000000 0%, red 100%); <!-- to see the layout being shifted -->
      }
    </style>
  </head>

  <body></body>
</html>
DrWarpMan commented 1 month ago

On some devices I tested, this issue does not happen:

While on others, it does:

I found a good example website where you can see this issue occur in "production", https://cobalt.tools: