Bite Sized Tech is a participant in Unity Affiliate Program, Liquid Web Affiliate Program, Hostinger Affiliate Program, Namecheap Affiliate Program, Envato Elements Affiliate Program, Adobe Affiliate Program and SteelSeries Affiliate Program under which we might earn commission when visitors use our Affiliate Links and makes qualifying purchases.


#4 Tauri Multi Process Architecture – Core & WebView Process | Minimalist Text Editor in Rust Programming Language & Tauri | Rust & Tauri Development Tutorial


Tauri is a toolkit to make Native Applications for Windows, Linux, macOS

(They are working on Support for Android, iOS and WASM)

while still using Web Technologies and Frameworks like HTML, JS, CSS, Svelte, Vue.js, etc

for the Front-end i.e. User Interface, as I’ve overviewed in the last article.

In this Article, we will be delving further down into the rabbit hole that is Tauri

and understand some of the inner working of Tauri by going over

  • Why Tauri uses Multi-Process Architecture
  • What is the Core Process in Tauri
  • and Finally, the WebView Process in Tauri

So, without further ado, let’s get started!


This Article is part of Minimalist Text Editor Using Rust and Tauri Tutorial Series


Minimalist Text Editor in Rust Programming Language & Tauri - #4 Tauri Multi Process Architecture - Core and WebView Process - Rust & Tauri Tutorial - Featured Image


Why Tauri Uses Multi-Process Architecture

If you have been using computers for decades now or if you have used some really old Applications

you would surely have come cross the situation where

when you interacted with the GUI (Graphical User Interface)

your application would become Unresponsive for a while during which your computer is calculating things.

Sometimes this unresponsiveness could last for tens of seconds or more

when some CPU intensive Tasks needed to be done, before it becomes responsive again.

The reason why this happens is the way these applications were made during those times,

where it was really a common practice to use a single process to

  • Perform Calculations
  • Draw The Interface
  • Manage User Inputs
  • and more

Now, if you have written some programs then you can understand that,

if all of these things are done inside the same process

then you will only be able to do one of these things at a given time,

i.e. you won’t be able to Manage User Inputs like Mouse Clicks

while you are Performing Calculations required by your application and vice versa.

This means that if a long-running, computationally heavy function or method is called

then everything else that this process needs to do will be blocked,

until this computationally heavy function returns.

Another deal breaking issue was that, if something went wrong in one of these components,

then the whole application will crash and fall like a house of cards, which is really not a good architecture.

This slowly became a huge issue as computers started becoming faster and more stable,

making this issue a lot more evident and as time went on it irritated a lot of people,

who slowly developed ways to mitigate this issue.

One of these solutions is to divide the application which is running on a single process

and then run each of the divided component in it’s own process.

This not only makes it so that Performing Calculations will not block us from Managing User Inputs and vice versa

but this will also isolate the crashes to their own processes

so that the whole application will not crash if something goes wrong.

This also makes it possible to restart just these crashed components if and when they do crash.

Isolating the components in their own processes also has a benefit of

being able to provide the minimum amount of access required to the components running inside a process

while disallowing any unnecessary requirements, which in turn will make your application more Secure.

For example, if the one or more processes doesn’t need access to the File System, we don’t give them that access.


Core Process in Tauri

The Core Process in Tauri can be considered the Brain of the Tauri Application

and is responsible for creating and managing

  • Application Window
  • System Tray Menu
  • Notifications
  • Global Settings
  • Database Connections
  • and more

It is the Entry Point of the Tauri Application and will be the only component in the whole application

which will have Full Access to the Operating System.

Tauri also routes all Inter-Process Communication through the Core Process, which allows you to

Intercept, Filter and Manipulate IPC Messages, all from the same location.

We will take a deeper look at How Inter-Process Communication works within Tauri in the next article.

One fact to remember is that, the Core Process does not render the UI itself,

it creates new WebView Processes to do so.


WebView Process in Tauri

The WebView Process leverages the WebView Libraries to open up a Browser-like Environment

that can execute code for HTML, CSS, JavaScript and various Frameworks like Svelte and Vue.js.

A WebView Library will already be pre-installed in the Operating System most of the time

but which WebView Library it is, will be based on the OS on which the Application is running.

Currently, Tauri uses

  • Windows – Microsoft Edge WebView2
  • Linux – webkitgtk
  • macOS – WKWebView

Tauri does not bundle the WebView Libraries in the Final Executable

because doing so will increase the binary size considerably (by about 150 MB).

Tauri instead dynamically links itself to the OS’s WebView Libraries at runtime.

Another benefit of leveraging the OS’s WebView Libraries is that,

The Operating System will make sure the User’s WebView Libraries are up-to-date,

making our Tauri Apps more Secure, without us, the developer, having to take any extra steps.


This Article is part of Minimalist Text Editor Using Rust and Tauri Tutorial Series



Conclusion

Well Folks! That does it for this article.

I hope that you found this information on Tauri’s Multi-Process Architecture useful.

In the next article, we will delve more into understanding How Inter-Process Communication works in Tauri.

May you have success in your career whatever it may be.

See you again in the upcoming articles!

Share this post on Social Media platforms, if you think our content is great.

If you like the content and would like to follow us, we are present on the platforms below

Follow Us On Social Media

Goodbye For Now,
This is your host VP
Signing Off.