Common browser architecture
It can be a process with many different threads, or it can be a process with several threads communicating through IPC.
A process with many different threads
Process of multiple threads communicating via IPC
note
These different architectures are implementation details. There is no standard specification on how to build a web browser. One browser method may be completely different from another
Chrome browser architecture
Chrome's official website architecture (18 years)
Chrome's latest architecture diagram (19 years)
Advantages and disadvantages of the multi-process model
advantage
- Stability, one page crash will not affect other pages, because different rendering processes are used
- Security and sandboxing, the browser can hourglass certain processes from certain functions. For example, the Chrome browser restricts any file access to processes that process any user input such as renderer processes.
Disadvantages
- Higher resource usage. Because each process will contain a copy of the common infrastructure (such as V8, which is Chrome's JavaScript engine), this means that the browser will consume more memory resources.
- More complex architecture. Problems such as high coupling and poor scalability between browser modules
Service-oriented architecture
In order to solve a series of problems brought about by the previous architecture, as early as 2016, the official Chrome team used the concept of "Services Oriented Architecture" (SOA) to design a new Chrome architecture. The original various modules will be reconstructed into independent services (Service). Access services (Service) must use a defined interface to communicate through IPC. Each service (Service) can run in a separate process Easily split into different processes or aggregate into one process. When Chrome runs on powerful hardware, it may split each service into different processes to provide greater stability, but if it is on a resource-constrained device, Chrome will integrate the services into one In order to save memory.
Official website service architecture diagram (18 years)
Chrome "service-oriented architecture" process model diagram (latest)
Process model diagram of Chrome "service-oriented architecture" (on resource-constrained devices)![image.png image.png](https://cdn.nlark.com/yuque/0/2020/png/305942/1587089219133-0c7ec32f-b773-4164-b450-cc13ffa8b000.png)
Chrome process
Main process
Browser process, rendering process, GPU process, network process, plug-in process
- Browser process
Mainly responsible for interface display, user interaction, sub-process management, while providing storage and other functions. Controls the "chrome" part of the application, including the address bar, bookmarks, back and forward buttons, and also handles the invisible and privileged parts of the web browser, such as network requests and file access.
- Rendering process
The core task is to convert HTML, CSS and JavaScript into web pages that users can interact with. The typesetting engine Blink and the JavaScript engine V8 are both running in this process. By default, Chrome will create a rendering process for each Tab tag. For security reasons, the rendering process is running in sandbox mode.
- GPU process
In fact, when Chrome was first released, there was no GPU process. The original intention of using GPU is to achieve the effect of 3D CSS. After that, the web page and Chrome UI interface have chosen to use GPU to draw, which makes GPU a common demand of browsers. Finally, Chrome also introduced GPU processes on its multi-process architecture.
- Network process
It is mainly responsible for loading the network resources of the page. It was previously run as a module in the browser process. It was only recently that it became independent and became a separate process.
- Plugin process
It is mainly responsible for the operation of the plug-in. Because the plug-in is easy to crash, it needs to be isolated by the plug-in process to ensure that the plug-in process will not affect the browser and page.
- utility process
Sometimes the browser main process needs to do some "dangerous" things, such as image decoding and file decompression. If these "dangerous" operations fail, it will cause an abnormal crash of the entire main process, which we do not want to see. So Chromium designed a mechanism for the utility process. When the main process temporarily needs to do some inconvenient tasks, you can start a utility process to replace the main process. The main process and the utility process communicate through IPC messages.
If there are currently other processes under the environment with sufficient resources ,
- UI process
- Stored process
- Device process
- Audio process
- Video process
- Profile process
- ........
development of
Given the complexity of the current architecture, it is estimated that it will take several years to complete the transition to a service-oriented architecture. However, Chrome development is a gradual process, and new features will be added a little bit, which also means that we can always see new changes in Chrome.
note
⚠️ The latest Chrome browser is currently on a service-oriented architecture, we can open the Chrome task manager to take a look
Reference link
Geek Time Browser working principle and time
Chrome official website https://developers.google.com/web/updates/2018/09/inside-browser-part1