How a Browser Works Flashcards
What are browsers based on?
Threads AKA a queue that processes tasks sequentially
Previous browsers were single thread. What does that mean?
Older browsers like IE6
What are some of the problems with single-thread browsers?
Instability, low performance, insecurity
With regard to instability, what exactly is the issue with single-thread browsers?
You can get a thread crash which leads to a stop in the process and causes the browser to freeze.
With regard to low performance, what exactly is the issue with single-thread browsers?
There are two things that we can potentially attribute to low performance:
1. Javascript takes time, and while it was executing the script, the page render thread waws being blocked.
2. Memory leakage - browser kernel complex. Garbage collection didn’t always work. The longer you used the browser, the more memory was taken from the system.
With regard to insecurity, what exactly is the issue with single-thread browsers?
Plugins could gain access to the OS with admin permissions via the single thread. Javascript can read sensitive information when you interact with the browser like password input.
What’s the primary advantage that a multi-threaded browser has over a single-threaded browser?
It can process faster because multiple threads can operate simultaneously. Threads share the date in memory.
What is the first step in loading a web page, and what are the two primary foes?
Navigation is the first step and it occurs whenever a user requests a page by entering a URL into the address bar, clicking a link, submitting a form, etc.
Latency and bandwidth are the two main enemies.
Give me a summary of what’s happening when a page gets displayed.
- The browser process handles user input and composes a URL request.
- Network process sends URL request initiating the Navigation phase.
- The browser process creates a renderer process after receiving the server response. The renderer process would be on standby at this point while the network process receives the document.
- The browser commits the navigation. Network process starts sending document data to the renderer process ending the navigation phase.
- The renderer process renders the document.
How many steps and how many processes in the broswer are around during the navigation phase?
5 steps:
1. Handling user input (BROWSER PROCESS)
2. Sending URL request (NETWORK PROCESS)
3. Prepare the render process (BROWSER PROCESS)
4. Committing navigation (RENDER PROCESS)
5. Rendering page (RENDER PROCESS)
Steps 2-4 are involved in the navigation process.
What does it mean to handle user input?
It all begins with a request for a web page - an HTML request. BEFORE the navigation process begins, the UI (user interface) thread in the browser process will parse the user input. There’s two distinct possibilities when there’s user input:
What’s happening when the user input is a search query?
During a search query, the keywords get parsed, a URL with the search query gets composed, and then a URL request is initiated.
What’s happening when the user input is a URL?
The address bar will attach protocol (usu. HTTP or HTTPS). For example, medium.com becomes https://medium.com. When the user hits return, the browser reads the URL from the address bar and sends the URL request to a network process via inter-process communication.
Sending a URL request is part of the network process during the Navigation phase. What’s happening?
The first step of navigating to a web page is finding where the assets for that page are located.
The Network process receives the command from the browser process to handle the URL request. First, the network process will take a look at the browser cache - it wants to see if the requested resource got saved locally. IF that resource has been saved locally, it returns the cached resource to the browser.
What happens with the Network Process when the requested resource has not been saved locally?
If you’ve never visited the site or the assets are not cached, then the browser will request a DNS lookup.