What is suppressesIncrementalRendering doing?

妖精的绣舞 提交于 2020-06-29 04:08:17

问题


I'm using the newest version of Xcode and Swift.

I was googling around to make my KWWebView even faster and found the following:

webConfiguration.suppressesIncrementalRendering = true

Documentation says the following:

A Boolean value indicating whether the web view suppresses content rendering until it is fully loaded into memory.

But what does this mean? Does it mean, the html doesn't not get rendered and shown as long as not all resources like images and javascript files are completely loaded by the WKWebView?


回答1:


As stated in the documentation it's a flag to tell the webview engine to wait or not till things are set and ready. whether to scan the document (html+related resources) to check for what to be redrawn periodically, or just await the full stuff to be loaded and ready.

WebEngine:

Rendering is a progressive process that depends on the assets (js, Css, images..) that will compose the page. It is important to understand that Turning this feature on or off will simply turn the algorithm of rendering on/off for loaded content.

How to make my page faster?

A lot of factors, rendering algorithm (engine's), how heavy your scripts are(bundle, memory allocation,event pass through and handling, etc..), the size of the images, how well structured your CSS is, and its hierarchical selector orgnisation(css parsing and application). The order of which the assets are loaded( included) in the page.

You can always check the profiling of your page in (devtools for example) on a modern browser to see how things go, what size of memory it allocates, the bundle size, time for scripting, how the page is designed to consume/utilise device resources.

To make the long story short:

Generally speaking there are THREE main phases with a total of five steps through which your page has to go while living in the browser:

PHASE A: MEMORY/CALCULATION (CPU)

1- Scripting:

PHASE B:( PROCESSING CPU mainly)

2- Styling

3- Layout

PHASE C: (GPU POWER!)

4- Paint

5- Composition

When the browser decides to to update it has to go through these, either a full pass or a partial pass will make a lot of difference. consider the following example

if you have a div, and you decided to create an animation that moves it from the left edge of the screen to the right edge, you see developers doing two approaches:

  • THOSE WHO JUST WRITE CODE: change the left value of the div style over time. ( simple right?)

  • THOSE WHO KNOW THE STUFF: do a transfom by using translateX or translate3D.

both ways will work, the first will eat up your CPU, while the second will run at a very high FPS.

WHY ?

The first approach plays with sacred left value, that means the browser will have to re-calculate the new left (STEP1) > check style (STEP2) > THEN do a new LAYOUT (STEP 3) > Do a Paint ( step 4) > THEN enter Composition phase (STEP 5)

this will cost a full pass 5 stages that is totally unnecessary!!

The other approach on the other hand, will not require anything but a composition (one step #5) because the matrix manipulation in the GPU (pretty strong ability!) can handle displacements implied by using the translate3d or translateX!! you will see people talking about including a translate3d prop on your CSS elements to push performance (huh!) but the real reason is the above explained. so knowing what happens under the hood can save you.

supperess rendering is about waiting to load everything before starting to show things up, or simply try to handle things as they load..



来源:https://stackoverflow.com/questions/62482781/what-is-suppressesincrementalrendering-doing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!