title: Webview showing blank spaces after updating Xamarin.Forms version 5.0.0.1874
body: <p>We are using WebView in Xamarin.Forms using custom renderer. When we have updated Xamarin.Forms version from 4.7.0.1260 to 5.0.0.1874 in our solution it is showing blank spaces at the end of WebView content. It is working fine in Xamarin.Forms version 4.7.0.1260. We have also tried latest version of Xamarin.Forms but there also getting same issue. Getting issue in both platforms Android and iOS.</p>
  <p>Please check the below code for the same.</p>
  <pre><code>---------//XAML//---------
  &lt;ScrollView&gt;
  &lt;Grid&gt;
      &lt;Grid.RowDefinitions&gt;
          &lt;RowDefinition Height=&quot;*&quot;/&gt;
      &lt;/Grid.RowDefinitions&gt;
      &lt;local:ExtendedWebViewModel x:Name=&quot;AppWebView&quot;                                                        
                              Grid.Row=&quot;0&quot;
                              HorizontalOptions=&quot;FillAndExpand&quot;
                              VerticalOptions=&quot;FillAndExpand&quot;/&gt;
  &lt;/Grid&gt;
  &lt;/ScrollView&gt;
  
  
  
  ---------//cs//-----------
  
  
  // xaml cs file code
  
  AppWebView.Source = new HtmlWebViewSource
  {
      Html = @&quot;&lt;!DOCTYPE html&gt;&lt;html&gt;&lt;head&gt;&lt;meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=5.0, minimum-scale=1.0, user-scalable=no'&gt;&lt;style&gt; *{ font-size:12px; font-family: Verdana !important; }&lt;/style&gt;&lt;/head&gt;&lt;body&gt;&quot; + System.Net.WebUtility.HtmlDecode(content) + @&quot;&lt;/body&gt;&lt;/html&gt;&quot;,                           
  };
  
  
  // ExtendedWebViewModel
  
  using Xamarin.Forms;
  
  namespace EmployeeApp.ViewModel
  {
      public class ExtendedWebViewModel : WebView
      {
      }
  }
  
  
  
  ---------//Android Custom Renderer//--------
  
  
  using Android.Content;
  using Android.Webkit;
  using EmployeeApp.Droid;
  using EmployeeApp.ViewModel;
  using Plugin.FirebaseCrashlytics;
  using System;
  using System.Reflection;
  using Xamarin.Essentials;
  using Xamarin.Forms;
  using Xamarin.Forms.Platform.Android;
  using WebView = Android.Webkit.WebView;
  
  [assembly: ExportRenderer(typeof(ExtendedWebViewModel), typeof(ExtendedWebViewRenderer))]
  namespace EmployeeApp.Droid
  {
      public class ExtendedWebViewRenderer : WebViewRenderer
      {
          static ExtendedWebViewModel _xwebView = null;
          WebView _webView;
  
          public ExtendedWebViewRenderer(Context context) : base(context)
          {
          }
  
          class ExtendedWebViewClient : Android.Webkit.WebViewClient
          {
              public override async void OnPageFinished(WebView view, string url)
              {
                  try
                  {
                      if (_xwebView != null)
                      {
                          int i = 10;
                          while (view.ContentHeight == 0 &amp;&amp; i-- &gt; 0) // wait here till content is rendered
                              await System.Threading.Tasks.Task.Delay(100);
                          _xwebView.HeightRequest = view.ContentHeight;
                      }
                      base.OnPageFinished(view, url);
                  }
                  catch (Exception ex)
                  {
                      CrossFirebaseCrashlytics.Current.Log(string.Format(&quot;SessionID : {0}, Pagename : {1}, Methodname : {2}, Error :  {3}&quot;, App.SessionID, MethodBase.GetCurrentMethod().ReflectedType.FullName, MethodBase.GetCurrentMethod().Name, ex.Message)); CrossFirebaseCrashlytics.Current.RecordException(ex);
                  }
              }
              
              public override bool ShouldOverrideUrlLoading(WebView view, IWebResourceRequest request)
              {
                  bool value = true;
                  try
                  {
                      Android.Net.Uri url = request.Url;
                      if (Convert.ToString(url).StartsWith(&quot;http&quot;))
                      {
                          var uri = new Uri(Convert.ToString(url));
                          Launcher.OpenAsync(uri);
                          value = true;
                      }
                  }
                  catch (Exception ex)
                  {
                      CrossFirebaseCrashlytics.Current.Log(string.Format(&quot;SessionID : {0}, Pagename : {1}, Methodname : {2}, Error :  {3}&quot;, App.SessionID, MethodBase.GetCurrentMethod().ReflectedType.FullName, MethodBase.GetCurrentMethod().Name, ex.Message)); CrossFirebaseCrashlytics.Current.RecordException(ex);
                  }
                  return value;
              }
  
          }
  
          protected override void OnElementChanged(ElementChangedEventArgs&lt;Xamarin.Forms.WebView&gt; e)
          {
              try
              {
                  base.OnElementChanged(e);
                  _xwebView = e.NewElement as ExtendedWebViewModel;
                  _webView = Control;
  
                  if (e.OldElement == null)
                  {
                      _webView.SetWebViewClient(new ExtendedWebViewClient());
                  }
              }
              catch (Exception ex)
              {
                  CrossFirebaseCrashlytics.Current.Log(string.Format(&quot;SessionID : {0}, Pagename : {1}, Methodname : {2}, Error :  {3}&quot;, App.SessionID, MethodBase.GetCurrentMethod().ReflectedType.FullName, MethodBase.GetCurrentMethod().Name, ex.Message)); CrossFirebaseCrashlytics.Current.RecordException(ex);
              }
          }
      }
  }
  
  
  ---------//iOS Custom Renderer//--------
  
  
  using System;
  using System.Reflection;
  using EmployeeApp.iOS;
  using EmployeeApp.ViewModel;
  using Plugin.FirebaseCrashlytics;
  using UIKit;
  using WebKit;
  using Xamarin.Forms;
  using Xamarin.Forms.Platform.iOS;
  
  [assembly: ExportRenderer(typeof(ExtendedWebViewModel), typeof(ExtendedWebViewRenderer))]
  namespace EmployeeApp.iOS
  {
      public class ExtendedWebViewRenderer : WkWebViewRenderer
      {
          protected override void OnElementChanged(VisualElementChangedEventArgs e)
          {
              try
              {
                  base.OnElementChanged(e);
                  NavigationDelegate = new AppWKNavigationDelegate(this);
              }
              catch (Exception ex)
              {
                  
              }
          }
      }
  
      public class AppWKNavigationDelegate : WKNavigationDelegate
      {
          readonly ExtendedWebViewRenderer extendedWebViewRenderer;
          public AppWKNavigationDelegate(ExtendedWebViewRenderer _extendedWebViewRenderer)
          {
              try
              {
                  extendedWebViewRenderer = _extendedWebViewRenderer ?? new ExtendedWebViewRenderer();
              }
              catch (Exception ex)
              {
                  
              }
          }
  
          public override async void DidFinishNavigation(WKWebView webView, WKNavigation navigation)
          {
              try
              {
                  if (extendedWebViewRenderer.Element is ExtendedWebViewModel extendedWebViewModel)
                  {
                      if (webView != null)
                      {
                          //string javascript = string.Format(@&quot;document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '{0}'&quot;, &quot;250%&quot;);
                          //WKJavascriptEvaluationResult handler = (NSObject result, NSError err) =&gt; { };
                          //webView.EvaluateJavaScript(javascript, handler);
                          await System.Threading.Tasks.Task.Delay(100); // wait here till content is rendered
                          if (webView.ScrollView != null)
                          {
                              if (webView.ScrollView.ContentSize != null)
                              {
                                  extendedWebViewModel.HeightRequest = (double)webView.ScrollView.ContentSize.Height;
                              }
                          }
                      }
                  }
              }
              catch (Exception ex)
              {
                 
              }
          }
  
          public override void DecidePolicy(WKWebView webView, WKNavigationAction navigationAction, Action&lt;WKNavigationActionPolicy&gt; decisionHandler)
          {
              try
              {
                  if (navigationAction != null)
                  {
                      if (navigationAction.NavigationType == WKNavigationType.LinkActivated)
                      {
                          if (navigationAction.Request != null)
                          {
                              if (navigationAction.Request.Url != null)
                              {
                                  UIApplication.SharedApplication.OpenUrl(navigationAction.Request.Url);
                                  decisionHandler(WKNavigationActionPolicy.Cancel);
                              }
                          }
                      }
                      else
                      {
                          decisionHandler(WKNavigationActionPolicy.Allow);
                      }
                  }
              }
              catch (Exception ex)
              {
                  
              }
          }
      }
  }
  
  </code></pre>
  <p>Can anyone please check and give any solution for the same?</p>