question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Android - WebView renders incorrectly on large heights

See original GitHub issue

Bug description:

When rendering a WebView that is too long, it shows a massive padding on top of rendered content. The height at which this happends depends on the device/emulator.

For example, on a Pixel XL emulator, WebView behaves as expected up until height: 4500. But once height is at around 5000 , it breaks.

To Reproduce:

import React from "react";
import { WebView } from "react-native-webview";
import { View } from "react-native";

  const webViewContent = {
    borderBottomColor: colors.paleGray,
    borderBottomWidth: 1,
    flex: 1,
    flexDirection: "row",
    opacity: 0.99,
    paddingHorizontal: 0,
    paddingVertical: 20,
    margin: 0,
    height: 5000,  //4500 works
    width: "100%"
  },

  const html = "This is a test".repeat(100)

  export default Content = () => {
    return (
        <WebView
          style={webViewContent}
          source={ { html }}
        />
    )
  };

Expected behavior:

Webview renders HTML string filling the whole screen.

Screenshots/Videos:

Height set to 4500 android_mobile_height_4500

Height set to 5000 android_mobile_height_5000

Environment:

  • OS: Android
  • OS version: 9
  • react-native version: 0.63.2
  • react-native-webview version: 11.13.0

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
arielflashnercommented, Dec 21, 2021

i had the same issue while using “androidHardwareAccelerationDisabled={true}” removing that fixed the issue

2reactions
r-kojimacommented, Aug 12, 2021

@kirhammer
I got same problem when tried to render too long HTML. But adding additional props androidLayerType="hardware" works correctly for me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

WebView doesn't shrink to fit the height of the page
I've been using a WebView to load different data (HTML data) and it's all working fine. But the problem comes when the WebView...
Read more >
Slow rendering - Android Developers
If these are taking a long time, first check the width and height numbers in the trace. Ensure that the bitmap being displayed...
Read more >
Android's WebView is broken - CleverTap
We render pure HTML and CSS inside Android's WebView, iOS' UIWebView, ... WebView rendered incorrectly in all versions of Android.
Read more >
Android WebView ScrollTo is wrong when scroll offset is big.
I further investigated the issue and put some logs in cc/. The problem lies in LayerTreeImpl::GetDelegatedScrollOffset. The outer viewport ...
Read more >
Tips for Getting Your Android Apps Looking Good on Amazon ...
You can think of the Amazon Fire TV screen as an Android device that is locked to landscape orientation, with a constant width...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found