# Compat Linux / Microsoft Teams



## marcelbonnet (May 10, 2020)

I recently upgraded to 12.1-RELEASE and updated my ports.

I attempted to install MS Teams RPM package from https://packages.microsoft.com/yumrepos/ms-teams/teams-insiders-1.3.00.958-1.x86_64.rpm

*Procedure 1: determine missing libs*


```
cd /tmp && rpm2cpio < /tmp/teams-insiders-1.3.00.958-1.x86_64.rpm | cpio -id
ldd /tmp/usr/share/teams-insiders/teams-insiders | grep "not found"
```

*Procedure 2: install to the correct place*


```
cd /compat/linux/
rpm2cpio < /tmp/teams-insiders-1.3.00.958-1.x86_64.rpm | cpio -id
```

*Procedure 3: install the needed packages (the list below has all my linux-c7, not only required by Teams)*


```
linux-c7-cups-libs-1.6.3_8
linux-c7-alsa-lib-1.1.8
linux-c7-alsa-lib-devel-1.1.8
linux-c7-alsa-plugins-oss-1.1.6_3
linux-c7-alsa-plugins-pulseaudio-1.1.6_1
linux-c7-alsa-utils-1.1.8
linux-c7-at-spi2-atk-2.26.2
linux-c7-at-spi2-core-2.28.0
linux-c7-atk-2.28.1_1
linux-c7-cairo-1.15.12_1
linux-c7-cairo-gobject-1.15.12_1
linux-c7-dbus-libs-1.10.24_1
linux-c7-dri-18.3.4_2
linux-c7-elfutils-libelf-0.176_1
linux-c7-elfutils-libs-0.176_1
linux-c7-expat-2.1.0_3
linux-c7-flac-libs-1.3.0_2
linux-c7-fontconfig-2.13.0
linux-c7-freetype-2.8_1
linux-c7-fribidi-1.0.2_1
linux-c7-gdk-pixbuf2-2.36.12
linux-c7-graphite2-1.3.10
linux-c7-gtk3-3.22.30_1
linux-c7-harfbuzz-1.7.5
linux-c7-jasper-libs-1.900.1_5
linux-c7-jbigkit-libs-2.0_2
linux-c7-jpeg-1.2.90_4
linux-c7-libasyncns-0.8_1
linux-c7-libdrm-2.4.91
linux-c7-libepoxy-1.5.2
linux-c7-libgcrypt-1.5.3_4
linux-c7-libglvnd-1.0.1
linux-c7-libgpg-error-1.12_2
linux-c7-libogg-1.3.0_1
linux-c7-libpciaccess-0.14
linux-c7-libpng-1.5.13_2
linux-c7-libsndfile-1.0.25_4
linux-c7-libthai-0.1.14_1
linux-c7-libtiff-4.0.3_4
linux-c7-libvorbis-1.3.3_2
linux-c7-libxkbcommon-0.7.1_1
linux-c7-lz4-1.7.5_1
linux-c7-nspr-4.21.0
linux-c7-nss-3.44.0_1
linux-c7-pango-1.42.4_1
linux-c7-pixman-0.34.0
linux-c7-pulseaudio-libs-10.0_2
linux-c7-sqlite-3.7.17_2
linux-c7-systemd-libs-219_6
linux-c7-tcp_wrappers-libs-7.6_2
linux-c7-wayland-1.15.0
linux-c7-xorg-libs-7.7_8
```

But, when I run /compat/linux/usr/share/teams-insiders/teams-insiders, the result is:

```
/compat/linux/usr/share/teams-insiders/teams-insiders
Trace/BPT trap
```

*EDIT:*
I tried without change `sysctl compat.linux.osrelease`
Then I tried change it to the same version show by `file`:

```
file /compat/linux/usr/share/teams-insiders/teams-insiders
/compat/linux/usr/share/teams-insiders/teams-insiders: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=053a55877047f85454dc430b8a11098509075575, stripped
sysctl compat.linux.osrelease=3.2.0
```

But it lead me to the same error.

Can you point me to make it work? (I know Teams is supposed to run with all features on www/chromium, but I rather it as a compatible application).
Cheers.


----------



## shkhln (May 10, 2020)

Are you familiar with LD_PRELOAD? Get yourself a copy of webfix.so from games/linux-steam-utils port and put it there. Pass _--no-sandbox_ and, optionally, _--single-process_ flags to the application as well.


----------



## marcelbonnet (May 11, 2020)

But you meant games/linux-steam-utils as an example of use of LD_PRELOAD to override a shared library and therefore to try to override some of the required libs? 

Or you mean webfix.so, found in that game port, may play a role in MS Teams ?


----------



## marcelbonnet (May 11, 2020)

Seriously, what webfix.so has to do with that? A different error is a one step forward. Thanks. I'll look for the missing file/dir.


```
LD_PRELOAD=/usr/local/steam-utils/lib64/webfix/webfix.so /compat/linux/usr/share/teams-insiders/teams-insiders
A JavaScript error occurred in the main process
Uncaught Exception:
Error: libsecret-1.so.0: cannot open shared object file: file or directory not found
    at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:143:31)
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:722:18)
    at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:152:18)
    at Module.load (internal/modules/cjs/loader.js:602:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:541:12)
    at Function.Module._load (internal/modules/cjs/loader.js:533:3)
    at Module.require (internal/modules/cjs/loader.js:640:17)
    at require (/compat/linux/usr/share/teams-insiders/resources/app.asar/external/v8-compile-cache/v8-compile-cache.js:173:28)
    at Object.<anonymous> (/compat/linux/usr/share/teams-insiders/resources/app.asar/node_modules/keytar4/lib/keytar.js:1:169)
    at Object.<anonymous> (/compat/linux/usr/share/teams-insiders/resources/app.asar/node_modules/keytar4/lib/keytar.js:55:3)
Trace/BPT trap
```


----------



## shkhln (May 11, 2020)

marcelbonnet said:


> Seriously, what webfix.so has to do with that?



It works around PR 240990, PR 240991 and one another not relevant here bug. I only tested it with Chromium Embedded Framework and not with Electron, though.


----------



## marcelbonnet (May 12, 2020)

Today I used Teams on www/chromium : audio works, I can share my desktop... (audio has some defect while and after I share my desktop, sounds like missing samples - cut audio, but still usable).

Supported clients: https://docs.microsoft.com/en-us/microsoftteams/get-clients says Chrome is supported.

But the goal was to run the RPM package. I Don't know what to do anymore. I'm stuck.

Thanks shkhln , anyway.


----------



## shkhln (May 12, 2020)

Had a look. Eventually it fails with a pretty obscure error:

```
teams-insiders[7660]: ../../third_party/electron_node/src/node_platform.cc:387:std::shared_ptr<PerIsolatePlatformData> node::NodePlatform::ForIsolate(v8::Isolate *): Assertion `data' failed.
...
4: 0x403773c v8::internal::MemoryReducer::MemoryReducer(v8::internal::Heap*)
...
8: 0x439a89a v8::Isolate::Initialize(v8::Isolate*, v8::Isolate::CreateParams const&)
```

There is no  obvious reason for this as far as I can see: no missing or failing syscalls. It's something relatively subtle, which means it's hard to catch.


----------



## marcelbonnet (May 12, 2020)

shkhln said:


> Had a look. Eventually it fails with a pretty obscure error:
> 
> ```
> teams-insiders[7660]: ../../third_party/electron_node/src/node_platform.cc:387:std::shared_ptr<PerIsolatePlatformData> node::NodePlatform::ForIsolate(v8::Isolate *): Assertion `data' failed.
> ...



I was not able to launch the app, it crashed at the very beginning.What about you?
Did you use a different command to run or the same as I did? What window manager are you using?

Cheers.


----------



## shkhln (May 14, 2020)

shkhln said:


> Eventually it fails with a pretty obscure error:



Looks like Electron doesn't like _--single-process_ switch. Meh.



marcelbonnet said:


> I was not able to launch the app, it crashed at the very beginning.What about you?




```
--- teams-insiders.orig    2020-01-10 01:56:24.000000000 +0300
+++ teams-insiders    2020-05-14 04:11:19.498988000 +0300
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/compat/linux/bin/sh

SCRIPT=$(readlink -f "$0")
USR_DIRECTORY=$(readlink -f $(dirname $SCRIPT)/..)
@@ -8,5 +8,7 @@

mkdir -p "$TEAMS_LOGS"

-nohup "$TEAMS_PATH" "$@" > "$TEAMS_LOGS/teams-insiders-startup.log" 2>&1 &
+export LD_LIBRARY_PATH=/usr/local/steam-utils/lib64/fakeudev:/usr/local/steam-utils/lib64/fakepulse:/compat/linux/lib64/nss
+export LD_PRELOAD=/usr/local/steam-utils/lib64/webfix/webfix.so

+"$TEAMS_PATH" --no-sandbox --no-zygote --in-process-gpu --v=0 "$@"
```

You'll have to install one missing library (libsecret) yourself. Try this with and without fakepulse in LD_LIBRARY_PATH.


----------



## shkhln (May 17, 2020)

So, was it actually worth it?


----------



## marcelbonnet (May 18, 2020)

shkhln said:


> So, was it actually worth it?


I'm sorry, it was impossible to test it before.
It seems to work!
I installed libsecret :


```
cd /compat/linux
wget https://centos.pkgs.org/7/centos-x86_64/libsecret-0.18.6-1.el7.x86_64.rpm.html
rpm2cpio libsecret-0.18.6-1.el7.x86_64.rpm | cpio -id
```

I modified the /compat/linux/usr/bin/teams-insiders as you said:


```
#!/compat/linux/bin/sh

SCRIPT=$(readlink -f "$0")
USR_DIRECTORY=$(readlink -f $(dirname $SCRIPT)/..)

TEAMS_PATH="$USR_DIRECTORY/share/teams-insiders/teams-insiders"
TEAMS_LOGS="$HOME/.config/Microsoft/Microsoft Teams - Insiders/logs"

mkdir -p "$TEAMS_LOGS"

#nohup "$TEAMS_PATH" "$@" > "$TEAMS_LOGS/teams-insiders-startup.log" 2>&1 &
export LD_LIBRARY_PATH=/usr/local/steam-utils/lib64/fakeudev:/usr/local/steam-utils/lib64/fakepulse:/compat/linux/lib64/nss
export LD_PRELOAD=/usr/local/steam-utils/lib64/webfix/webfix.so

"$TEAMS_PATH" --no-sandbox --no-zygote --in-process-gpu --v=0 "$@"
```

Ran as normal user this script.

I cannot fully test it now. But during the next days I'll try chatting, audio e video calling. But, I was able to login and post a video and a notice in one of my Corporation groups.

It is probably leaking . Look at the numbers in sysutils/htop:

_(node:12930) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 appInitialized listeners added. Use emitter.setMaxListeners() to increase limit_






Anyway, it's cool.
Thank you so much shkhln . I'll report during the next days.


----------



## marcelbonnet (May 18, 2020)

I searched for other options to launch MS Teams in hope to diminish CPU load: `strings  /compat/linux/usr/share/teams-insiders/teams-insiders | grep "\-\-"` . I tried most of them, but cpu hits 100% all the time.


----------



## shkhln (May 18, 2020)

Most? Try disabling GPU acceleration.


----------



## marcelbonnet (May 18, 2020)

shkhln said:


> Most? Try disabling GPU acceleration.



You're right, I should have documented the "most" switches I've used. Thanks for this link, I didn't know about it.

Basically I tried these switches. Test 1 with same results (100% CPU load) and Test 2 with a different result.

Disabling GPU made no difference. Maybe I should mix with other swtiches? I tried some.
*
Test 1*


```
"$TEAMS_PATH" --no-sandbox --no-zygote --in-process-gpu --v=0 "$@"
"$TEAMS_PATH" --no-sandbox --no-zygote --in-process-gpu --v=0 --single-threaded-gc "$@"
"$TEAMS_PATH" --no-sandbox --no-zygote --in-process-gpu --v=0 --single-threaded-gc --disable-gpu"$@"
"$TEAMS_PATH" --no-sandbox --no-zygote --in-process-gpu --v=0 --disable-gpu"$@"

"$TEAMS_PATH" --no-sandbox --no-zygote --v=0 --single-threaded-gc --disable-gpu \
--disable-gpu-appcontainer \
--disable-gpu-compositing \
--disable-gpu-driver-bug-workarounds \
--disable-gpu-early-init \
--disable-gpu-lpac \
--disable-gpu-memory-buffer-compositor-resources \
--disable-gpu-memory-buffer-video-frames \
--disable-gpu-process-crash-limit \
--disable-gpu-process-for-dx12-vulkan-info-collection \
--disable-gpu-program-cache \
--disable-gpu-rasterization \
--disable-gpu-sandbox \
--disable-gpu-shader-disk-cache \
--disable-gpu-vsync \
--disable-gpu-watchdog "$@"

"$TEAMS_PATH" --no-sandbox --no-zygote --v=0 --single-threaded-gc --force-gpu-mem-available-mb=10 --gpu-program-cache-size-kb=512 "$@"
"$TEAMS_PATH" --no-sandbox --no-zygote --v=0 --single-threaded-gc --memory-pressure-off "$@"
"$TEAMS_PATH" --no-sandbox --no-zygote --v=0 --single-threaded-gc --disable-audio-output "$@"
"$TEAMS_PATH" --no-sandbox --no-zygote --v=0 --single-threaded-gc --disable-audio-support-for-desktop-share "$@"

"$TEAMS_PATH" --no-sandbox --no-zygote --v=0 --num-raster-threads= from 0 to 6
"$TEAMS_PATH" --no-sandbox --no-zygote --v=0 --disable-gl-drawing-for-tests
"$TEAMS_PATH" --no-sandbox --no-zygote --v=0 --disable-gesture-requirement-for-presentation
"$TEAMS_PATH" --no-sandbox --no-zygote --v=0 --disable-histogram-customizer
"$TEAMS_PATH" --no-sandbox --no-zygote --v=0 --disable-low-res-tiling
"$TEAMS_PATH" --no-sandbox --no-zygote --v=0 --disable-software-rasterizer
"$TEAMS_PATH" --no-sandbox --no-zygote --v=0 --disable-partial-raster --disable-renderer-backgrounding --disable-renderer-accessibility --disable-rtc-smoothness-algorithm
"$TEAMS_PATH" --no-sandbox --no-zygote --v=0 --disable-partial-raster --disable-renderer-backgrounding --disable-renderer-accessibility --disable-rtc-smoothness-algorithm --disable-software-rasterizer
"$TEAMS_PATH" --no-sandbox --no-zygote --v=0 --webrtc-max-cpu-consumption-percentage=10
```


*
Test 2*

Finally I've got something different: I put all the --disable-* switches :
no CPU load , but my GUI is blank and absolutly useless! 
Now I have to play with those switches.


----------



## marcelbonnet (May 18, 2020)

Switch --disable-threaded-compositing  turns the GUI blank and CPU load to 0.

Sounds like is it possible to fix with other switch? I have no idea, yet. I need to eliminate the rest of those --disable-* to discover by brute force.


----------



## shkhln (May 19, 2020)

marcelbonnet said:


> Sounds like is it possible to fix with other switch?



We don't know if that is an issue with Linuxulator, my workarounds or an application itself. I don't see an easy way to find that out either. It would be interesting to try some other Electron applications for comparison. Any suggestions?


----------



## rootbert (May 19, 2020)

maybe you would like to give a vote at https://techcommunity.microsoft.com/t5/teams-developer/ms-teams-with-freebsd/m-p/1360158


----------



## tanis (Sep 11, 2020)

@marcelbonnet did you make it work, like the full package, audio, video, and screen sharing?


----------



## marcelbonnet (Sep 12, 2020)

No....


----------



## YuryG (Sep 13, 2020)

As far as I can see it, Linux's MS Teams has just build-in variant of Chrome in it.


----------



## break19 (Sep 29, 2020)

Try with this flag, to fix the black screen issue after disabling composite:
`--override-use-software-gl-for-tests`
I was getting a similar black screen for Discord and it seems to work now that I've added this flag, using the above script as a skeleton.


----------



## xtouqh (Sep 29, 2020)

We need newer linux base for a lot of applications now, centos8 or, better yet, ubuntu 18.04 lts, someone?


----------



## trasz@ (Oct 16, 2020)

Already done: https://wiki.freebsd.org/LinuxJails


----------



## twschulz (Oct 19, 2020)

trasz@ said:


> Already done: https://wiki.freebsd.org/LinuxJails


Just wondering. It says 12-Stable on the wiki page. Are the majority of the changes going to be part of 12.2-RELEASE?


----------



## trasz@ (Oct 19, 2020)

Yes.


----------

