Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Linux browser panel support [CEF 4280 / Chromium 87] #254

Merged
merged 2 commits into from
Jan 26, 2021

Conversation

cg2121
Copy link
Contributor

@cg2121 cg2121 commented Dec 8, 2020

TODO

  • Needs more testing (tested on Ubuntu 20.04 with QT 5.12.8)
  • Un-hardcode obs-browser.so lookup
  • Fix random crashes that sometimes happen

Description

Add Linux browser panel support.

Screenshot from 2020-12-08 14-39-41

Motivation and Context

Bringing the browser plugin to parity with Windows.

How Has This Been Tested?

Needs testing on other OSs to make sure it doesn't break anything.

Types of changes

  • New feature (non-breaking change which adds functionality)

Checklist:

  • My code has been run through clang-format.
  • I have read the contributing document.
  • My code is not on the master branch.
  • The code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

Copy link
Member

@RytoEX RytoEX left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few notes based on a visual readthrough. I imagine between this and #197, one will need rebased when the other is merged.

CMakeLists.txt Outdated Show resolved Hide resolved
panel/browser-panel.cpp Outdated Show resolved Hide resolved
panel/browser-panel.cpp Outdated Show resolved Hide resolved
panel/browser-panel.cpp Outdated Show resolved Hide resolved
@cg2121 cg2121 force-pushed the linux-browser-panels branch 2 times, most recently from 214af24 to df2b745 Compare December 8, 2020 21:35
@cg2121
Copy link
Contributor Author

cg2121 commented Dec 8, 2020

All requested fixes in the review are now fixed.

Copy link
Member

@RytoEX RytoEX left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple more things.

panel/browser-panel.cpp Show resolved Hide resolved
panel/browser-panel.cpp Show resolved Hide resolved
@WizardCM
Copy link
Member

WizardCM commented Dec 9, 2020

Ubuntu 20.04:

error: X Error: BadWindow (invalid Window parameter), Major opcode: XI_BadMode (invalid Mode parameter), Minor opcode: 46, Serial: 250

When I create a custom browser dock.

terminate called after throwing an instance of 'std::logic_error'
what(): basic_string::_M_construct null not valid
Aborted (core dumped)

When I try to open the Service Integration window (specifically to connect Twitch).

Browser sources work fine.

@WizardCM
Copy link
Member

WizardCM commented Dec 9, 2020

OK, after a bit of debugging myself, the cause for the second error above is

CefString(&settings.cache_path) = path.Get();

Essentially, path.Get() returns null.

BPtr<char> rpath = obs_module_config_path(storage_path.c_str());
BPtr<char> path = os_get_abs_path_ptr(rpath.Get());

I think this is because the value it's based on, rpath, ends up being an absolute path rather than an expected relative path, so the conversion fails.

panel/browser-panel.hpp Outdated Show resolved Hide resolved
@cg2121 cg2121 force-pushed the linux-browser-panels branch 2 times, most recently from 206952e to 89fefca Compare December 9, 2020 23:27
@cg2121
Copy link
Contributor Author

cg2121 commented Dec 9, 2020

Service integration should be working with the latest push.

@WizardCM
Copy link
Member

error: X Error: BadWindow (invalid Window parameter), Major opcode: XI_BadMode (invalid Mode parameter), Minor opcode: 46, Serial: 250

I've spent a few hours trying to bypass this error. No luck. If I remove the windowInfo.SetAsChild call, a secondary window does open, but that's not the goal.

I tried a number of variations, including using this->effectiveWindowId() or manually setting windowInfo.parent_window. Everything would return the same error.

The only way I was able to change the behaviour is using XConfigureWindow and XReparentWindow after CreateBrowserSync, which leaves an extra empty black window which then freaks out and cannot be closed. The panel itself renders correctly but cannot be interacted with or resized.

I don't know X well enough to be able to do this using X functions correctly.

@cg2121
Copy link
Contributor Author

cg2121 commented Dec 10, 2020

@WizardCM could you check if it works better for you now? I removed all of the QT functions from the CEF threads, and it seems it is more stable. It also seemed to work better on the latest CEF (CEF 4280).

@WizardCM
Copy link
Member

WizardCM commented Dec 10, 2020

@cg2121 Nice work! I can confirm that they now correctly appear inside the dock (and within the Service Integration login container).

As a side note, I'm using CEF 4183 as that's what we hope to upgrade to.

However, while the child windows are correctly added, the following things don't work:

  1. I cannot click within the webpage to interact with it (either within a dock, or service integration login)
  2. Resizing the dock/login doesn't resize the webpage, and instead shows the empty container
  3. When closing service integration login, both BadWindow: 25 and BadWindow: BadName occur (if I resize before closing, I also get BadWindow: BadColor for every resize event) Fixed in CEF 4280
  4. After triggering 3, on shutdown I get Trace/breakpoint trap (core dumped) - the breakpoint is at ../sysdeps/nptl/futex-internal.h Fixed in CEF 4280

@cg2121
Copy link
Contributor Author

cg2121 commented Dec 11, 2020

@WizardCM the crash on exit appears to only happen on CEF 4183, but resizing and clicking work fine for me.

@WizardCM
Copy link
Member

WizardCM commented Dec 11, 2020

@cg2121 Hmm, in that case I might try bumping to 4240 or 4280 for my testing.

I doubt that'll fix resizing and clicking though, if my experience so far is anything to go by. :(

@WizardCM
Copy link
Member

@cg2121 I can confirm that 4240 doesn't have any change in behaviour at all, but 4280 fixes the crash on shutdown and the two BadWindow errors when closing service integration login.

The rest of the issues remain.

@WizardCM WizardCM changed the title obs-browser: Add Linux browser panel support obs-browser: Add Linux browser panel support [CEF 4280 / Chromium 87] Dec 11, 2020
@WizardCM WizardCM changed the title obs-browser: Add Linux browser panel support [CEF 4280 / Chromium 87] Add Linux browser panel support [CEF 4280 / Chromium 87] Dec 11, 2020
@RytoEX
Copy link
Member

RytoEX commented Dec 11, 2020

Needs testing on other OSs to make sure it doesn't break anything.

What OS did you test on so far? Can you please add that information to the original post?

@cg2121
Copy link
Contributor Author

cg2121 commented Dec 11, 2020

I've tested it so far on Ubuntu 20.04 with QT 5.12.8.

@phedders
Copy link

phedders commented Dec 11, 2020 via email

@cg2121
Copy link
Contributor Author

cg2121 commented Dec 11, 2020

@WizardCM by chance, are you using a VM to test it?

@WizardCM
Copy link
Member

@WizardCM by chance, are you using a VM to test it?

Correct, I'm using my PXE boot in a Hyper-V VM. For some reason it has had trouble booting on real hardware recently, I hope to troubleshoot that this weekend.

@cg2121
Copy link
Contributor Author

cg2121 commented Dec 12, 2020

The obs-browser library lookup is now un-hardcoded. Requires obsproject/obs-studio#3871 to work.

@eNBeWe
Copy link

eNBeWe commented Dec 13, 2020

I just built this code on Ubuntu 20.04:

  • With the CEF version from the obs-studio documentation (3770) the browser contents are super tiny (approx 1% zoom level)
  • With CEF 4280 the first tests look quite promising
    • The embedded browser is unable to play twitch streams. I would like to use it to monitor the outgoing stream, which doesn't work because of this.
    • Apart from that it seems to be able to do what I need it to do
  • I would like to test the twitch integrations, but can't authenticate to twitch with the locally built version.

@cg2121
Copy link
Contributor Author

cg2121 commented Dec 13, 2020

I've fixed the Windows resize issue. All I had to do was to set the window container as frameless.

@WizardCM
Copy link
Member

I can confirm that the lib lookup function works perfectly, even with nonstandard locations for OBS.

Heads up: the issues I was running into with resizing and interaction are caused by the USE_QT_LOOP CMake flag, which is designed to fix conflicts between Qt, CEF & GTK. I have this enabled to emulate production builds as much as possible. Getting browser panels to work properly with this flag will require a fair bit of rework of the panel code, but should solve a lot of issues.

  • With the CEF version from the obs-studio documentation (3770) the browser contents are super tiny (approx 1% zoom level)

@eNBeWe This is why we use 3809 on Linux. Basically, 3770 doesn't seem to set the default font size, so all text is tiny (everything else should be fine). Alternatively, add this commit.

  • The embedded browser is unable to play twitch streams. I would like to use it to monitor the outgoing stream, which doesn't work because of this.

This is likely because non-free codecs are not enabled in Spotify builds.

panel/browser-panel.hpp Outdated Show resolved Hide resolved
@cg2121
Copy link
Contributor Author

cg2121 commented Dec 19, 2020

With the newer CEF versions (tested with 4280), the USE_QT_LOOP on Linux doesn't seem necessary. From what I can tell, the crashes don't happen anymore with newer CEF versions, as I haven't been able to reproduce them.

@cg2121
Copy link
Contributor Author

cg2121 commented Dec 19, 2020

If that turns out to be the case, then this PR is ready to go.

@cg2121
Copy link
Contributor Author

cg2121 commented Dec 19, 2020

Confirmed with another developer that they aren't getting the crashes anymore either, so as is this can be merged without problems, at least for Linux.

@PatTheMav
Copy link
Member

OK, after a bit of debugging myself, the cause for the second error above is

CefString(&settings.cache_path) = path.Get();

Essentially, path.Get() returns null.

BPtr<char> rpath = obs_module_config_path(storage_path.c_str());
BPtr<char> path = os_get_abs_path_ptr(rpath.Get());

I think this is because the value it's based on, rpath, ends up being an absolute path rather than an expected relative path, so the conversion fails.

@tbodt added a fix for this in #197, so maybe adapt that here as well?

I guess merging #197 first makes sense, then the PRs for "modern" CEF versions required for macOS (because that would include CEF 4280 as well), and finally this PR?

@cg2121
Copy link
Contributor Author

cg2121 commented Dec 23, 2020

I've added the fix from #197. It also works on Linux without problems.

@flexiondotorg
Copy link

Thank for working on this! I've been testing on Ubuntu 20.04 with OBS 26.0.1 with the following patches applied:

I've also dropped USE_QT_LOOP=TRUE from my build. Working great, no issues encountered.

@LiamDawe
Copy link

LiamDawe commented Dec 31, 2020

Tested the Snap package mentioned to me by @flexiondotorg ( https://snapcraft.io/obs-studio ), looking good over here on Arch Linux. Docked my Twitch chat window without issues.

@WizardCM
Copy link
Member

@cg2121 Now that macOS panel support has been merged, please rebase your branch.

In the meantime, I'm going to try and get USE_QT_LOOP on linux to behave, just so we don't destroy existing configurations if possible. It won't be a requirement for this PR to be merged, but it's something I think would be worth doing.

@cg2121
Copy link
Contributor Author

cg2121 commented Jan 17, 2021

It has been updated to the latest master.

@Krutonium
Copy link

Krutonium commented Jan 26, 2021

I managed to get this going, but when I tried to embed https://pretzel.rocks/ the player seems to be unable to function - it errors out playing each song and immediately skips to the next song.

@WizardCM WizardCM merged commit 3cd1a98 into obsproject:master Jan 26, 2021
@cg2121 cg2121 deleted the linux-browser-panels branch January 27, 2021 00:03
@WizardCM WizardCM added this to the OBS Studio 27.0 milestone Mar 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants