The whole process includes two sub processesNavigationandRendering
- The user enters the URL and returns
- The browser process checks the URL and assembles the protocol to form a complete URL
- The browser process sends the URL request to the network process through IPC
- After receiving the URL request, the network process checks whether the local cache has cached the request resource, and if so, returns the resource to the browser process
If not, the network process initiates an HTTP request (network request) to the server. The request process is as follows:
DNS resolution, access to the server’s IP address, port
- Local domain name server view local cache
- Root domain name server
- Top level domain name server
- Authoritative domain name server
- Using IP address and port to build the interface socket of interprocess communication, the end of subsequent TCP end-to-end transmission also refers to the socket
- Establishing TCP connection (three handshakes)
- The request line, request header and request body are constructed, and the established TCP connection is used to send the constructed request information
- The server receives the request information, constructs the response line, response header and response body, and sends them to the client through the established TCP connection
- The network process of the client browser receives the response header and response information, and parses the response content
Network process parsing response process
- Check the status code. If it is 301 / 302, it needs to be redirected. Automatically read the address from location and perform the fourth step again. If it is 200, continue to process the request
200 response processing
- Check the content type of the response. If it is a byte stream type, the request will be submitted to the download manager, and the navigation process will end without subsequent rendering. If it is of text / HTML type, the browser process is informed that it is ready to render, and the process is ready to render
Preparing the rendering process
- The browser process checks whether the current URL is the same as the main domain name of the URL of the previously opened page. If it is the same, the rendering process of the previous page will be reused. If not, a new rendering process is created
Transmit data, update status
- When the rendering process is ready, the browser process sends a “submit document” signal to the rendering process
- After receiving the signal, the rendering process establishes a “pipeline” to transmit data with the network process
- After data transmission, the rendering process sends the “confirm submit” signal to the browser process
- After receiving the confirmation signal, the browser process updates the status of the browser interface: security information, address bar URL, forward and backward history status, update web page, etc
- The rendering process converts the HTML content into something that can be readDOM treeStructure. (the stack is used to realize, when it meets “< p”, it will enter the stack, and when it meets “< / P”, it will exit the stack
- The rendering engine converts CSS style sheets into a format that the browser can understandstyleSheetsTo calculate the style of the DOM node. structureRender tree。
- establishLayout treeAnd calculate the layout information of the elements.
- The layout tree is layered and generatedHierarchical tree。
- Generate for each layerDraw listAnd submit it to the composition thread.
- The compositing thread divides the layer into two partsBlock, and inRasterized thread poolConverts a block to a bitmap.
- Composition thread sends drawing block commandDrawQuadTo the browser process.
- Browser process based on drawquad messageGenerate pageAnd display it on the display.