Some thoughts on the new Microsoft Teams 2.0 architecture (WebView2/ReactJS)
Tags: windows, desktop, webview2
Published: 2021-07-17 12:38:13

**Updated on 2021/07/24**, Electron.js has published a great article on [comparing Electron to WebView2](https://www.electronjs.org/blog/webview2). It's reassuring to know an improved form of IPC (between the WV2 host and JavaScript) is coming, in form of [CBOR](https://cbor.io).

<hr>

If you've been following the news from the remote collaboration software industry, you've probably heard that Microsoft Teams have migrated from **Electron/Angular** to **WebView2/React** for the upcoming version 2.0, which is also a part of Windows 11. A tweet by Rish Tandon, the CVP of engineering for Teams:

{% twitter 1408085784016539653 %}

As a software engineer who is involved in both web conferencing tools and Windows Desktop app development, I've been curious about this move. Particularly, whether or not they may also be utilizing .NET on the Desktop now, along with WebView2 (and JavaScript interop via [WebView2 IPC](https://docs.microsoft.com/en-us/microsoft-edge/webview2/how-to/javascript)). 

I thought, as long as they don't use Electron anymore and are being more Windows-centric now, they might as well be leveraging the power of .NET to do some media pre-processing on the client side. Similar to what [Zoom is doing with WebAssembly](https://webrtchacks.com/zoom-avoids-using-webrtc), but potentially, in a more efficient way with some compiled .NET code?

I didn't have a chance to install any insider builds of Windows 11 yet, but [with a little help from a fellow redditor](https://www.reddit.com/r/MicrosoftTeams/comments/olunv3/now_that_teams_20_uses_webview2_is_there_any/), I managed to get a sneak peek into Teams 2.0 internals, using SysInternals' excellent [ListDLLs tool](https://docs.microsoft.com/en-us/sysinternals/downloads/listdlls).

Take these thoughts with a grain of salt, currently they are just mine (somewhat educated) guesses/speculations.

- Teams 2.0 appears to be a Windows Store package, it's installed under "C:\Program&nbsp;Files\WindowsApps". Presumably, it can be listed from PowerShell with `Get-AppxPackage -allusers *teams*`.<br><br>

- *I could not detect any traces of the .NET runtime DLLs* in the memory space of the new Teams process. It does look like they use some Azure C++ SDK DLLs (`azure-core.dll`, `azure-storage-blobs.dll`, `azure-storage-common.dll`), a set of [Boost C++ libraries](https://www.boost.org/) (`boost_*.dll`) and [SQLite](https://www.sqlite.org/index.html) (`sqlite3.dll`, presumably for storing the app's local state).<br><br>

- They use WebView2 (aka WV2) in [shared "evergreen" mode](https://docs.microsoft.com/en-gb/microsoft-edge/webview2/concepts/distribution#stay-compatible-in-evergreen-mode) ("C:\Program&nbsp;Files&nbsp;(x86)\Microsoft\EdgeWebView\Application\91.0.864.70\EBWebView\x64\EmbeddedBrowserWebView.dll").<br><br>
- It's now a single-instance `msteams.exe` process. This may look as a departure from the multi-process architecture of Electron, but of course, WV2 still runs a bunch of its own `msedgewebview2.exe` processes. No surprise here, as it's still a customized version of Chromium under the hood.<br>
Is this pool of WV2 Chromium processes shared across other WV2 instances? I don't think so, but let's [ask the WV2 team](https://github.com/MicrosoftEdge/WebView2Feedback/issues/1542) directly.<br><br>

- It's hard to tell if they just use pure [WebRTC API](https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API) inside WebView2, or do some custom video processing on the client, but I haven't spotted any FFmpeg-like DLLs or anything that might look like custom codecs (the Electron-based version of Teams does bundle `ffmpeg.dll`, although it might just be a part of Electron runtime).

Overall, Teams 2 appears to be a basic [WinUI 3 Desktop C++ App](https://docs.microsoft.com/en-us/windows/apps/winui/winui3/create-your-first-winui3-app?tabs=desktop-cpp), *not* using WinForms, WPF or any other .NET libraries, with all-HTML UI made with React and hosted in WV2. Except, perhaps, for the UI pieces like top-level menus bar, status bar and Windows native notifications. 

I actually haven't seen the full UI yet, but such approach would make sense if they still aim to share the UI codebase between the Desktop app and the browser web app (at https://teams.microsoft.com). The HTML UI is most likely built with [Fluent UI React](https://www.microsoft.com/design/fluent/#/web), in line with the rest of Office 365.

One issue I've myself dealt with while hosting WV2 in a WPF app was [with accelerator keys of native peer WPF controls and menus](https://github.com/MicrosoftEdge/WebView2Feedback/issues/468#issuecomment-855810839), when the focus is inside WV2. It'll be interesting to see if a Win UI 3 host app is also affected by this, how Teams 2.0 deals with this.

That's the whole picture I've got for now. I'd appreciate if someone who might know more could jump in and correct me. I'll be updating this post as I learn anything new about Teams 2.0 architecture.