SpacingBat3 / WebCord

A Discord and SpaceBar :electron:-based client implemented without Discord API.
MIT License
1.89k stars 94 forks source link

Feature/screenshare with audio #346

Closed kakxem closed 6 months ago

kakxem commented 1 year ago

I resolved the conflicts, but I can't try the changes until this weekend.

orowith2os commented 1 year ago

Builds are failing:


Error: sources/code/common/main.ts(127,8): error TS2307: Cannot find module 'node-pipewire' or its corresponding type declarations.
Error: sources/code/main/windows/main.ts(29,35): error TS2307: Cannot find module 'node-pipewire/build/types' or its corresponding type declarations.
Error: sources/code/main/windows/main.ts(49,10): error TS2307: Cannot find module 'node-pipewire' or its corresponding type declarations.
Error: sources/code/main/windows/main.ts(56,54): error TS7006: Parameter 'node' implicitly has an 'any' type.
Error: sources/code/main/windows/main.ts(59,38): error TS7006: Parameter 'node' implicitly has an 'any' type.
Error: sources/code/main/windows/main.ts(576,18): error TS2307: Cannot find module 'node-pipewire' or its corresponding type declarations.
Error: sources/code/main/windows/main.ts(579,69): error TS7006: Parameter 'node' implicitly has an 'any' type.
Error: sources/code/main/windows/main.ts(580,67): error TS7006: Parameter 'node' implicitly has an 'any' type.
Error: sources/code/main/windows/main.ts(583,71): error TS7006: Parameter 'node' implicitly has an 'any' type.
Error: sources/code/main/windows/main.ts(583,77): error TS7006: Parameter 'index' implicitly has an 'any' type.
Error: sources/code/main/windows/main.ts(616,22): error TS2307: Cannot find module 'node-pipewire' or its corresponding type declarations.
Error: sources/code/main/windows/main.ts(626,71): error TS7006: Parameter 'port' implicitly has an 'any' type.
Error: sources/code/main/windows/main.ts(628,47): error TS7006: Parameter 'link' implicitly has an 'any' type.
Error: sources/code/main/windows/main.ts(640,65): error TS7006: Parameter 'node' implicitly has an 'any' type.
Error: Final attempt failed. Child_process exited with error code 1
linuxmobile commented 1 year ago

I test this package with archlinux + wayland, and it work fine! i can screenshare and everything looks fine! Native discord can't do that. Thx for it <3

IceDBorn commented 1 year ago

@kakxem I built this on Arch and NixOS, my streams do not transmit any sound at all. Wayland + Pipewire (tried it on Hyprland, Gnome, Awesome)

SpookySkeletons commented 1 year ago

Using this now, one question. There's no window share available? I appear to only be able to select entire screens and not windows.

orowith2os commented 1 year ago

That depends on your compositor, wlroots is limited to full screens. Other compositors are fine.

SpookySkeletons commented 1 year ago

Using kwin, anything odd in my setup I can check?

GraithTiger commented 1 year ago

Not working for me. Screen sharing working, but no audio sink listed in Pipewire. It appears that the node-pipewire module isn't loading?

Built with @\SpacingBat3's PKGBUILD for webcord-git

Error: Cannot find module './index.node'
Require stack:
- /usr/share/webcord/app.asar/node_modules/node-pipewire/build/index.js
- /usr/share/webcord/app.asar/app/code/common/modules/node-pipewire-provider.js
- /usr/share/webcord/app.asar/app/code/main/windows/main.js
- /usr/share/webcord/app.asar/app/code/common/main.js
- /usr/lib/electron/resources/default_app.asar/main.js
- 
    at Module._resolveFilename (node:internal/modules/cjs/loader:963:15)
    at Function.n._resolveFilename (node:electron/js2c/browser_init:2:109411)
    at Module._load (node:internal/modules/cjs/loader:811:27)
    at Function.f._load (node:electron/js2c/asar_bundle:2:13330)
    at Module.require (node:internal/modules/cjs/loader:1035:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/usr/share/webcord/app.asar/node_modules/node-pipewire/src/node/index.ts:4:17)
    at Module._compile (node:internal/modules/cjs/loader:1141:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1196:10)
    at Module.load (node:internal/modules/cjs/loader:1011:32) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/usr/share/webcord/app.asar/node_modules/node-pipewire/build/index.js',
    '/usr/share/webcord/app.asar/app/code/common/modules/node-pipewire-provider.js',
    '/usr/share/webcord/app.asar/app/code/main/windows/main.js',
    '/usr/share/webcord/app.asar/app/code/common/main.js',
    '/usr/lib/electron/resources/default_app.asar/main.js',
    undefined
  ]
}
SpacingBat3 commented 1 year ago

Not working for me. Screen sharing working, but no audio sink listed in Pipewire. It appears that the node-pipewire module isn't loading?

Built with @\SpacingBat3's PKGBUILD for webcord-git

Error: Cannot find module './index.node'
Require stack:
- /usr/share/webcord/app.asar/node_modules/node-pipewire/build/index.js
- /usr/share/webcord/app.asar/app/code/common/modules/node-pipewire-provider.js
- /usr/share/webcord/app.asar/app/code/main/windows/main.js
- /usr/share/webcord/app.asar/app/code/common/main.js
- /usr/lib/electron/resources/default_app.asar/main.js
- 
    at Module._resolveFilename (node:internal/modules/cjs/loader:963:15)
    at Function.n._resolveFilename (node:electron/js2c/browser_init:2:109411)
    at Module._load (node:internal/modules/cjs/loader:811:27)
    at Function.f._load (node:electron/js2c/asar_bundle:2:13330)
    at Module.require (node:internal/modules/cjs/loader:1035:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/usr/share/webcord/app.asar/node_modules/node-pipewire/src/node/index.ts:4:17)
    at Module._compile (node:internal/modules/cjs/loader:1141:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1196:10)
    at Module.load (node:internal/modules/cjs/loader:1011:32) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/usr/share/webcord/app.asar/node_modules/node-pipewire/build/index.js',
    '/usr/share/webcord/app.asar/app/code/common/modules/node-pipewire-provider.js',
    '/usr/share/webcord/app.asar/app/code/main/windows/main.js',
    '/usr/share/webcord/app.asar/app/code/common/main.js',
    '/usr/lib/electron/resources/default_app.asar/main.js',
    undefined
  ]
}

@GraithTiger Native Node.js modules extracting/building (they can't be in app.asar and might be needed to be rebuilt according to Electron docs) is currently unsupported by my PKGBUILD. You can't use it for this repo, sorry.

SpookySkeletons commented 1 year ago

KDE appears to have two different screen sharing portals? I think the default is screen only.

GraithTiger commented 1 year ago

@GraithTiger Native Node.js modules extracting/building (they can't be in app.asar and might be needed to be rebuilt according to Electron docs) is currently unsupported by my PKGBUILD. You can't use it for this repo, sorry.

I was able to get it working by compiling a separate node-pipewire package and including it in the dependencies along with a few other tweaks. Audio sharing appears to be working properly now.

System info: Kernel: 6.1.9-arch1-2 Desktop: KDE Plasma 5.27.2 Compositor: KWin-X11 Pipewire 0.3.66

PhantomShift commented 1 year ago

Using this now, one question. There's no window share available? I appear to only be able to select entire screens and not windows.

@SpookySkeletons This appears to be an issue with the latest version of electron (not sure if this is a known/reported bug?) as downgrading from major version 22 to 21 solved the issue you mentioned for me, giving me the choice to choose either a screen or a window.

Otherwise I can say that audio sharing seems to be working fine on both x11 and wayland (Arch, KDE Plasma), even streamed gameplay for a couple of hours when I had initially intended to just test to see if the feature was working.

SpookySkeletons commented 1 year ago

@PhantomShift Any word on latest electron 24? Webcord just updated latest 4.2.0 build to it.

EDIT: I am unable to downgrade as electron sub 23 suffers a bug that crashes the renderer during long call sessions.

beh-10257 commented 1 year ago

@SpookySkeletons I just made this issue in the brave browser https://github.com/brave/brave-browser/issues/29710 since well I guess they can at least post an issue in chromium issue tracker so yeah that's cool

SpookySkeletons commented 11 months ago

Hello, may we get a rebase of this branch to help anyone wanting to still roll these patches?

kakxem commented 10 months ago

@SpacingBat3, the last pipeline says something about 'enums' in lines 391, 394, 395...

I'm checking the code and I found the enums you've used for representing different favicon states could be causing the error. Could you please check this particular part of your code?

Thanks!

SpacingBat3 commented 10 months ago

Could you please check this particular part of your code?

If that's since the new TypeScript - will do once I'll move myself to it, right now I'm nowhere near my main dev machine and I might lack of the time...

ThatOneCalculator commented 6 months ago

Is this relevant anymore, given #154 ?

SpacingBat3 commented 6 months ago

For upstream, not really, but this PR still inspires me to make things modular in the future and to allow people replacing some Electron stuff with their own native modules for better integration. I kinda feel bad about entirely killing this PR.

I should also say, both this PR's and Electron's implementations have their advantages and disadvantages, I think with this one you have a greater control over the audio within the application, yet again Electron's implementation is much more portable and doesn't rely on PipeWire at all (for some this is a bad thing, but given there are still distros that are PulseAudio only, I still think it's more portable to implement things based on Pulse than PipeWire).

kakxem commented 6 months ago

My primary goal was to enable screen sharing with sound directly, without relying on external programs or scripts. If the proposed solution had been implemented, It's a win!

It's a bit sad that the PR was closed but I understand the decision of choosing the native solution. Although it's a bit limited in what you can do, I think it'll be easier to maintain.

Despite the outcome, I'm satisfied with the knowledge and skills I've acquired during this process.

beh-10257 commented 6 months ago

@kakxem I have used this pr for a very long time And well all I can say is it works beautifully with qpwgraph It gives me all the power and tricks I need

Hope the native solution is in the same boat Thanks for your hard work