by pelagicAustral · 3y ago · 0 comments
Honestly, I wish we could just skip straight to nothing but web apps. They work, they work consistently, they work cross platform.
Native apps are absolutely no guarantee you don't have performance problems, and I really don't think it's the render time for HTML/CSS in a webview that's slowing things down.
Most times it's just poor consideration for performance from the get-go. Chuck in a bunch of screens that are fetching remote resources before being displayed and viola... MS Teams.
----
Trust me, the development team that fucks up performance with Electron will absolutely fuck it up with native too.
This is like blaming the shitty bathroom remodel on the choice of tile instead of the poor craftsmanship.
Why must you curse us like that? Web apps became such a clusterfuck because HTML and the world-wide-web were never intended to run applications, but more and more was piled upon it until it somehow did.
Apps in the browser have shown undeniable advantages, but now that we've seen what we need, why not design a cross-platform toolkit that allows web apps through a protocol actually designed for applications. Something like Java/Flash tried to do, but using what we learned about web apps, back ends, and standardization.
https://docs.google.com/document/d/1oDBw4fWyRNug3_f5mXWdlgDI...
By the way, one of the wild-card impacts of GPT-4 might be that native apps arise again. It's very good at translating code from one platform to another.
Microsoft is celebrating a "massive" performance improvement which means Teams, which mostly renders text chat, opens in 10s instead of a minute. I really doubt native apps would have delays like that.
I really doubt the performance issues are based on the webview's performance rendering text. If so, VSCode wouldn't exist... and it does exist.
I haven't used angular in a long time, so you could maybe convince me that it's a shite framework from a performance perspective (I'd believe this, honestly) but I still bet money the delay is not local processing delays, but waiting for remote resources.
• No multi-threading, by implication you can't do things like deserialize large object graphs on a background thread. To get data to your UI you have to deserialize it on the UI thread, leading to jank.
• JS is a JIT compiled dynamically typed language. The memory overhead compared to C++ or even AOT compiled Java is correspondingly higher.
• DOM/CSS are extremely generic because they have to satisfy both document and app use cases. They're both low and high level simultaneously. On one hand that's great for making interactive documents - an important class of thing that non-web tech mostly ignores - on the other hand it means a lot of branches in hot paths, stringly-typed everything, big code footprint in the renderer, heavy objects, high level libraries can't use shared memory and more. The header file for Blink's DOM Element class is ~2000 lines by itself.
• No modularity whatsoever at any level. HTML just accretes more and more stuff as the years go by. There's no way to opt out, or select a lighter weight faster renderer. As it grows, memory usage and CPU time goes inexorably upwards despite fantastically huge budgets thrown at optimizing it.
• The one-size-fits-all sandboxing model imposes enormous overheads. Do I really need apps from well known brands like GitHub or Slack to be strongly sandboxed? Not really. It's nice to have a safety net in case of exploits, but I don't actually need these apps to be treated as radioactive all the time and the cost of doing so is very high. Native apps can use the latest DirectX on Windows, where hw features appear first, but Chrome serializes OpenGL command streams from the renderer across process boundaries and then does extensive validation before rendering them.
• JS was never designed for large teams. Why did Java become so popular in the enterprise? Because it has lots of rules and features that are intended to let lots of devs work together without stepping on each others toes or making too much of a mess. JS doesn't have the same approach.
It all adds up!
Personally - I'd prefer to be on linux full time, but work issues macbooks, and I develop applications that run across all three, so I use all three.
Web apps many times don’t even work on the same platform with browser dependencies. Ever had to load a web page on a different browser to get it to work?
Web tech is easy. This incidentally makes stuff built with it likely to be slower. Especially when you have a whole bunch of developers working on a thing. I have come to the conclusion that large teams more or less cannot produce good results by these sorts of measures.
I suspect also (without ever having used it) that a good chunk of Teams’ slowness will be in communications pieces that are nothing to do with web tech.
Ding ding ding. This is the winner. I have yet to see someone who is bitching about Electron actually show that the render time in the client is really what's causing the performance issues.
Almost always the issue is that fetching/updating a remote resource is just slow. It's SO freaking slow compared to local access.
Worse - almost every other aspect of computing is actually getting quite a bit faster, but RTT isn't going to change.
---
In this case, I'm willing to bet actual money that most of the speedup is hiding in what they're calling the "Client data layer" here: https://techcrunch.com/wp-content/uploads/2023/03/new_teams_...
No one planned for a situation where you have a rats nest or 100’s of MB and sometimes even GBs of JavaScript code running in a browser, since just like with the 140K of RAM or w/e it was is enough for everyone one then JavaScript and the existing patterns were good enough when no one could load enough of it to cause actual performance concerns in the first place.
I understand that you have lots of people building features but I'm sure the performance engineering efforts can be focused on the fundamental platform layers which are seen in most flame-graphs.
Its also exactly these companies that grill you on performance and leet-code type problems but ship nothing like what they interview for.
Picking good smart architectures is so hard. The people least capable of judging have tons of power & they almost all push for simpler, almost always minize the challenges.
Now that they've won over a large part of the instant messenger sector (every corporate place I've seen uses MS Teams), hopefully they'll chill out a bit and work on making it less clunky.
Message formatting in particular does my head in. Please just let we write markdown, and stop trying to live-replace backticks with rich-text-esque code blocks that I then can't move the cursor around!
You can build terrible software that is native and you can build good software on the web. Microsoft makes bad software, but this is not (at least entirely; you could argue that it encourages it) the web's fault. Look at the clusterfucks Microsoft's native apps are (they're the worst on their own platform ...). They just have extremely low standards for quality.
As a separate argument, this entire point might be moot. Native webviews are becoming more common (hell MS has used them for the OS for quite a while - when I was there working on the windows 10 start menu, it was actually a webview) and can be much more performant. Since you aren't bundling a full browser in the executable, the memory impact is quite low. Tauri seems to be gaining quite a bit of traction which leverages native webviews, and shows a lot of promise.
Twice as slow is slightly less? What about losing to competition because your app is slow and doesn’t feel like it belongs in the operating system? Or what about the cost and potential failure of a rewrite of a more complex app requiring technology the existing team has no experience with?
It's funny that the locally installed Photoshop took about 20s to launch, while Photopea launches instantly. Native is not necessarily better if it's poorly implemented.
Sublime Text is a great example of what performance can be like with a different toolkit. Compare it to vscode - even on a fast machine - and you'll start to notice all the little lags that can creep in.
It’s still mainly just a text editor and not “full-blown”. There is no significant built-in user interface, gui designer/builders, or emulators for example. The plugins can be native, which could allow for this. Essentially, vscode is a text editor that allows for native plugins, which explains the high performance possible.
The issue is in the application architecture, not the platform architecture.
VSCode uses raw TS with no frameworks and all handcrafted events (manually attaching and detaching dom event listeners is commonplace, and hand wiring each event’s propagation chain is as well), Teams hops to the current flavor of the week framework when they get too far up a tree with the last rewrite’s.
VSCode has also never been rewritten from the ground up, whereas this is Teams’ fourth or fifth time by my count.
VSCode also has about 50 people on it, all said and done (PM, Design, etc included), teams has well over a thousand.
It’s really quite an interesting case study. The lesson being, IMO: stop worrying about electron vs native vs angular vs rust vs react vs blah blah blah and just:
- don’t be afraid to write good code
- profile often
Electron is a waste of resources. A high price to pay for the convenience of easy multiplatform applications.