title: WKWebView does not re-render content while loading another URL
body: <p>I'm currently developing an application that uses a <code>UIWebView</code> to display some content. It used to work fine with <code>UIWebView</code>, but we decided to switch to <code>WKWebView</code> when we raised the OS requirement to 8.1. We noticed a huge improvement in performance, but some simple think that used to work fine, started failing now. After some research, I managed to see what's going on - but I don't see how to fix it. I was wondering if someone could lend me a hand on this...</p>
  
  <p>The URL our webview loads takes quite a lot of time to finish the job, so before starting the request we load a static spinner so the user doesn't feel like the app has gone nuts. The load cycle for that static content is already tuned up, so we don't start the URL request until the static content has been correcty loaded. This works fine, as long as the user doesn't rotate the device. This is what can be seen:</p>
  
  <p>(I had to change the view for privacy purposes. I'm not the owner of this code, after all :-))</p>
  
  <p><img src="https://i.stack.imgur.com/a3TNb.png" alt="enter image description here"></p>
  
  <p>I'm using this html code to test the size. The body's background color is dark gray, and the ugly light gray box expands to the 100% of the width, substracting the margins. So far so good. But if the user rotates the device, this is what happens:</p>
  
  <p><img src="https://i.stack.imgur.com/bb6uE.png" alt="enter image description here"></p>
  
  <p>This is creepy, since apparently the body's stetching to match the maximum width, but the inner div is handling a wrong relative size. This goes on as long as the request is being processed. When I force a timeout to make the request fail, the <code>WKWebView</code> re-renders and shows its correct appearance:</p>
  
  <p><img src="https://i.stack.imgur.com/BQ7Zo.png" alt="enter image description here"></p>
  
  <p>Once I discovered this I tried, without success, to subscribe to the rotation observer and force re-renders on the webview by:</p>
  
  <ul>
  <li>Calling <code>viewNeedsDisplay</code> for both the <code>UIWebView</code> and the <code>UIScrollView</code> inside</li>
  <li>Re-sizing the <code>UIWebView</code></li>
  <li>Re-positioning the <code>UIScrollView</code> content</li>
  </ul>
  
  <p>So, my conclusions so far:</p>
  
  <ul>
  <li>This didn't happen on an <code>UIWebView</code>, just on the new <code>WKWebView</code> (I tested this again, confirmed)</li>
  <li>Looks like <code>WKWebView</code> doesn't render views correctly while it's on loading status</li>
  </ul>
  
  <p>Does somebody know if there's a way to fix this? Something like one magical property I'm missing that comes disabled by default? I don't want to think they broke this part when they remade the webview... Thanks in advance :)</p>
  
  <p><strong>Edit:</strong> Stuff I tried since the creation of the post, without success:</p>
  
  <ul>
  <li>Changing the DOM asyncronally, through the use of javascript/native rotation callbacks <strong>doesn't work</strong>. The changes don't get rendered until the http request ends.</li>
  <li>Calling the http request in a different thread using the <code>dispatch_async</code> method <strong>doesn't work</strong>. Under the hood, the <code>WKWebview</code> probably ends up using the same thread as if you call it from the main thread.</li>
  </ul>