Electron multiple Tabs without dealing with performance

Series

  1. Why shouldn't use the normal tab on the same browser
  1. How can we do that? Pros & cons
 
Hi everyone,
In the journey of building a tool to interact with Firestore, I found an insight that:
  • Developers usually work on multiple projects at the same time
  • And they also tend to use multiple tabs on the browser to work with the same Firebase project to have multiple views
Indeed, Refi App should support them by:
  1. Implement user's familiar UX tabs - Like what chrome does
  1. Hotkeys all the thing (Cmd + T for a new tab, Cmd + W to the closing current one)
  1. Fast
 

In search of solutions

It popped out on my head for some solution:
  • Just use some Tabs component, there are hundred of Tabs components out there
But none of them can give me the right solution, why?
If I use Tabs component in react, the multiple application will work on just one process and it app is will hang when we have more than 3 tabs open since Refi App do lots of things in the background: It listens to the database changes and update the UI in realtime, showing many documents at the same time in the Table view
How about electron-tabs, it uses webview under the hood. I tested it and end up can not make my app run properly due to application architecture. The webview also have many issues remains that event Slack or Figma team can not deal with:
 
Refi App architecture
Refi App architecture
 
But those awesome team has introduced a great alternative solution for it BrowserView. It basically works like BrowserWindow but you can put BrowserView anywhere in of BrowserWindow.
It likes position relative/absolute in CSS, the BrowserWindow is the parent which has position: relative; and the BrowserView is a child has position: absolute;. And yes, you can put many BrowserView inside its parent as you want, just like CSS
 
BrowserWindow = position relative, BrowserView = position Absolute
BrowserWindow = position relative, BrowserView = position Absolute

Here is the output

Refi App Tabs architecture
Refi App Tabs architecture
 
Video preview
 
The output is awesome, each tab instance has its own process, and the performance is incredible, it like we change tab in the Chrome browser (In fact, the mechanism is almost the same as Chrome is doing)
 
If you guys think this post is useful and one to know more tricks on optimizing the performance of Electron, let's follow me at https://twitter.com/cuthanh15
 

Loading Comments...

Follow me @cuthanh15

🥶

Mình đang chạy thử quảng cáo Google Adsense, nếu có bất tiện thì cho mình xin lỗi nhé, sẽ gỡ sau 1 tháng chạy thử