Taste: spicy fried tripe
Cooking time: 10min
This article has been included in GitHub, a warehouse with the same name in the front-end canteengithub.com/GeekhytWelcome to the canteen. If you think the food and wine are delicious, a star is a great encouragement to the canteen owner.
Last night when I moved the brick home, I saw Peter send a circle of friends, and Tencent cloud game platform start released the public beta. He was playing lol with Mac. I followed closely and experienced a wave. After all, lol is the youth of our generation. I seldom have time to play after work. After using mac, the previous game books have been kept at the bottom of the box for a long time.
Choose an EZ wave ~
The first victory is easy in 20 minutes (after all, S2 old players, match the regular operation), the comprehensive experience is still very good, the home network speed can not feel the delay, except that the mouse is a little uncomfortable when adjusting the view angle in the window mode. (students who want to experience should turn off the trigger angle first.)
The “cloud” mode of cloud game platform completely liberates the imagination of “cross platform”. With the arrival of 5g, is it possible that it is the best solution to cross platform in the future? For our front-end engineers, what new challenges are waiting for us? Students are welcome to leave a message to discuss ~
The book goes back to the main story. Recently, he is working on the project of electron. Electron has made a lot of efforts to realize cross platform. (it’s just in contrast to the cloud game platform.) Let’s have a look.
Browser architecture evolution
Let’s start with the evolution of browser architecture. The increasingly complex business requirements push the continuous evolution and iteration of browser architecture.
Take our favorite
ChromeFor example, from the single process architecture before 2007 to the current multi process architecture, browsers have changed their architecture,
Become more stable, smoother and safer. The latest you can see right now
ChromeThe browser should include the following processes:
1 browser main process
1 GPU process
1 network process
Multiple rendering processes (running in sandbox mode)
Multiple plug-in processes
However, software engineering has no silver bullet. With the adjustment of browser architecture, it becomes more complex, and also has higher resource consumption.
How to find a balance between resource occupation and complex architecture has become a difficult problem.
Only children make choices, I want fish and bear’s paws!
In 2016, the chrome team designed a new chrome architecture using the idea of "services oriented architecture" (SOA).
ChromeThe team reconstitutes modules into independent services（
Service）The service runs in an independent process. If you want to access it, you must use a defined interface
IPCTo communicate. Such an architecture is undoubtedly more cohesive, loosely coupled, easy to maintain and expand.
ChromeOpen source version of is also a browser.
- Main process
RenderProcessHostAnd rendering process
- Of the rendering process
RenderView: our page is based on
WebkitIt’s displayed by typesetting.
ResourceDispatcherProcess resource requests. When the page needs to request resources, the
ResourceDispatcher, create a request
BrowserProcess and then return.
- Exposed in various processes
Native API (Main Native API、Renderer Native API)
So, in the
ElectronYou can use the
Node.jsDo something fun!
However, before that, there is still a difficulty to be solved: how to
There are two main ways to solve this problem
The first option,NW.jsThat’s what it does.
ElectronIn the early stage, it was also tried in this way. The results showed that it was easy to implement in the rendering process, but it was very troublesome in the main process, because of the various systems
GUIThe implementation is different,
glibIt is not only a huge amount of work, but also very difficult to deal with some boundary conditions.
Later, the author tried again, polling with a small interval timer
GUIVery slow response,
CPUIt’s also a big watch.
backend_fdIs equivalent to
libuvThe file descriptor of the event is polled so that the
backend_fdTo get it
libuvIt’s a new event. That is to say, the second way of thinking is to
If you want to know more, you can also go to the following author’s Zhihu answer ~
ElectronA new safe thread is started to poll
Node.jsThere is a new event after passing
ChromiumIn the event loop of the
- Working principle and practice of browser Li Bing
- Deng Yaolong
❤️ Three strikes of love
1. If you think the food and wine in the canteen are still acceptable, please give me a complimentFabulousIt’s my biggest motivation.
2. pay attention to the front desk of the official account.Eat every meal!
3. Like, comment, forward = = = urge to change!