About the single/multi-process of mobile web and browsers

Source: Internet
Author: User

Recently, Firefox OS (the original Boot to Gecko) pushed mobile web further, not only through the web runtime environment, but also the entire application architecture and runtime environment. All APIs are based on the web, belongs to the system level. Although it is about to launch a commercial machine next year, it will also throw stones in the industry. After cloud computing, Web/HTML5 is now a popular term for speculation. Before that, we talked about the impact of HTML5 on the ecosystem and analyzed it from the perspective of the Industrial Ecosystem chain, this time, we will start from the application perspective.

User-oriented: a false proposition of web or native

Developers develop an application targeting users. The platform only relies on the existing platform technology, that is, what content or services can be provided to users under the UI/UX. The starting point of application development is the user. The choice of web or native is based on the characteristics of the application, and the specific port on which native platform is the feasible cost budget of the target user and the developer.

Everything returns to simple economics: which users are oriented to applications, what values are provided by applications for users, what are the characteristics of applications, and the costs and benefits of developing applications. Finally, choose web or native based on these decisions.

It is meaningless to simply discuss the advantages and disadvantages of web and native. For example, native simply uses wide coverage to praise the web. Actually, there are two versions of iOS and Android? Not many. As for Symbian and BREW, these reasons are not so convincing considering the user base of applications and the development of low-price smartphones. Which applications are suitable for the web and which applications are suitable for native are the key.

Generally, it requires excellent user experience and uses the underlying functions of the system, that is, it has deep requirements and is suitable for native applications. It focuses on content embodiment, especially the expansion of PC browser services, it focuses on cloud capabilities, which are widely needed and suitable for web applications.

The depth or breadth, the dependence on terminals, or the cloud are two important dimensions.

Underlying functions, including graphic acceleration and sensor usage. These are said to be provided in HTML5. HTML5 can indeed provide standard interfaces, but the support for underlying functions must be supported by platforms and OEMs. HTML5 supports simple games and is quite old-fashioned. However, the current 3D complex graphics processing capabilities are still insufficient.

Smart terminals are combined with Smart Home and smart logistics. If customization is involved, native is a natural choice, at least in the early stages.

Internet applications, SNS, Weibo, newspapers, magazines, and other publishing industries are suitable for the web. Android has a large degree of fragmentation. It has screens of different sizes, and the web has a self-layout function. It can adapt to the terminal size in a certain range, or carry the size when requesting content, adapted from the cloud. Terminals are an extension of services for Internet-based cloud services.

Mobile web technology is lacking

Web has many advantages, such as low threshold and low maintenance cost, and avoids app store sharing. Why does some publishers give up applications and press injection on the web to give reasons for publishing industry and content providers to select web. There is no problem with the launch of web technology, but it still lacks release and copyright protection in application economics, as well as its own security, efficiency, and experience.

Performance constraints: HTML, CSS, and JS are script languages. parsing in the web runtime environment is less efficient than binary code execution or java bite code in the intermediate language, performance is lower than the limit that native cannot break through.

Limited underlying functions: HTML5 supports many local functions, including adding offline storage, 2D image capabilities, video/audio streams, geographic locations, access to mobile phone cameras and sensors, and user interface tools. However, for in-depth underlying functions that utilize the Media Processing of hardware chips, the 3D graphics library (OpenGL call) is still limited and can only call encapsulated functions.

New features lagging behind: All new functions of the platform are implemented in the platform itself, that is, native, and then supported by the web runtime environment. native applications take the lead in using new functions, the web running environment supports up to the next version.

Copyright protection:The script language can view the original code and has defects in protecting the intellectual property rights of applications. Of course, content providers with copyrights on the cloud are not a problem, but it is a headache for general developers who need to make profits.

Security Questions: IOS and Android both regard the application as a single user running in the sandbox, that is, security measures for the process. We start a browser on the PC, no matter how many pages we open above, it is still a browser process. HTML5 provides access to local sensitive information, such as contacts, whether the application opened in the same web runtime environment is isolated from the application. The security question is: does the web Support multi-process? And new performance problems: if each mobile web application needs to enable a web runtime, will it cause a large amount of device resources consumption.

Differences between single process and multi-process

It should be noted that this is irrelevant to HTML5. HTML5 is only a set of API standard interfaces and does not include the specific implementation of the system.

If you only have a single process, you cannot use the security protection mechanism provided by the underlying native system. You must provide a new security framework. In addition to security issues, a single process also has a major problem: a crash may cause the entire process to crash, that is, other web running on the process.

This is irrelevant to HTML5. HTML5 is only a set of API standard interfaces, and does not include the specific implementation of the system.

For web applications that use cross-platform tools, such as PhoneGap and MoSync, they can be used as native applications. For example, Android uses the WebView control in this application, encapsulates the complete web runtime. Different applications are different independent processes, as shown in. This is not in our scope of discussion.

We need to discuss the following two situations:

1. widgets enabled in the widget pannel through the widget Manager

2. Open a URL in a browser. Multiple applications may be opened in different browser windows, which may be different tags in the browser.

Single-process webkit

Webkit browsers, such as Android browsers, are single-process. Whether the system browser is enabled or the specified url in the application is called through intent, the system has a unique process com. android. browser.

There are two problems in this case:

1. Stability and robustness issues (I have always had a strong opinion on translation robustness): the crash of a single APP will cause the entire browser crash, that is, all apps running on the browser will crash.

2. Security Issues: different apps run in the same process. Currently, HTML5 supports many local sensitive operations, including storage, user information, how to isolate these apps, and how to provide their own security within a process.

Not long ago, Mozilla launched a completely web Operating System: Firefox OS. Mozilla's PC browser supports multiple processes, but it is unclear what it is like in Firefox OS? Only security issues caused by a single process can be solved for commercial use.

Solution: multi-process

With the promotion of HTML5, the web capabilities become larger, in addition to implementing more applications, but also taking greater responsibilities.To ensure the normal operation and safe operation of applications, the solution is to divide a single process into multiple processes, and they are isolated from each other to ensure that any one of them is invalid and will not endanger all of them.

Multi-process has different methods. One is a multi-process applied, that is, a parent-child process. One is a master process with multiple sub-processes, and the other is an independent multi-process. The former has the same user ID and security policy, while the latter can adopt the security architecture of the native system. Both methods can solve stability and robustness.

Google Chrome and Microsoft IE8 took the lead in implementing multi-process, followed by Mozilla Firefox, and soon implemented in other WebKit-based Web browsers, such as Apple Safari.

WebKit2

WebKit2 supports multiple processes. Because it is incompatible with the original WebKit in the API, It is renamed WebKit2. Web content (JS, HTML, and layout) is separated from the application UI in an independent process and directly provides process separation in the framework. This facilitates other WebKit-based clients, such as chat client, mail client and so on can benefit from this, that is, the app part can remain unchanged.

The process boundary is under the API boundary. Some Webkit processes the application logic in the App UI process. The remaining WebKit, WebCore, and JS engines process the actual rendering in the web process. These two processes are independent of each other, which makes it possible to securely place the web process in the sandbox.

Two subsystems support process separation: CoreIPC and DrawingArea. CoreIPC, as its name implies, is the communication between the UI process and the web process, including message transmission and events. DrawingArea is a cross-platform abstract drawing area. It has multiple cross-graph policies. Simply put, it is a bitmap with shared memory.

WebPageProxy in WebKit (UI Process) transmits the url through IPC and calls the web Process. The webkit (web process) of web process performs network processing and The webCore performs rendering, if an HTML5 url has malicious code, the corresponding web process will crash without affecting the running of other apps.

Chrome

Chrome is the first browser that supports multi-process processing and is also the most responsible. In Chrome, process decomposition is over the API boundary. It is optimized as a multi-process application, and proxy and process management are performed on its own. That is to say, this is the method of parent and child processes. Instead of being an independent process in webKit2, the system ensures security. The related work is provided by Chrome.

Chrome has four main process types: 1. browser process (that is, Host process in the figure), processing the browser user interface and managing all other processes; 2. render preocess, A render process can process one or more tabs. An example of a single tab and multiple tabs is shown in the figure, that is, one or two renderviews are added. 3. plugin process; 4. extension process.

Microsoft IE 8 browser

Microsoft adopts a similar implementation structure, also known as Loosely-Coupled IE (LCIE ). Extract browsing process from rendering process. The main process includes a browser, UI, and framework (windows), including a tab. Multiple Tabs can be processed in the same process, but they must be separated if they have different security levels. The AtviceX control is handled by the tab process.

Mozilla

According to the Mozilla situation, the implementation idea is basically the same. In the documents, the early version of Firefox 3.6.4 beta builds is provided, which is mainly to separate the plug-in of the browser.

Now Mazilla has launched the mobile operating system Firefox OS, and the web operating environment will become the operating environment for all applications of the system, so there must be an effective multi-process mechanism.

References and instructions:

[1] WebKit: the architecture of WebBrowser

[2] http://news.softpedia.com/news/Multi-Processes-in-Browsers-Chrome-Internet-Explorer-Firefox-and-WebKit-140535.shtml

[3] http://trac.webkit.org/wiki/WebKit2

[4] http://hi.baidu.com/ksoftware/blog/item/590b65ee2beb38e1b3fb9559.html

[Note] in the above figures, I painted the blue dotted box. Because I didn't do code-level research, it is my current way of cognition.

Related Links: My articles on Industrial Ecosystem chain and Miscellaneous

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.