obsproject / obs-browser

CEF-based OBS Studio browser plugin
GNU General Public License v2.0
786 stars 226 forks source link

obs-browser CSS problems: Cannot read property 'appendChild' #251

Closed JackobStuard closed 3 years ago

JackobStuard commented 3 years ago

I have problems with the obs-browser element. When I add CSS code for some browsers I see in log weird error: obs-browser: Uncaught TypeError: Cannot read property 'appendChild' of null (source: www.example.com:1)

Platform

Operating system and version: macOS Mojave 10.14.6 OBS Studio version: 26.0.2

Expected Behavior

The obs-browser element needs to load instantly.

Current Behavior

I see now that when I add CSS code that need 1-2 minutes to load CSS code for obs-browser

Steps to Reproduce

In obs log i only see error code: obs-browser: Uncaught TypeError: Cannot read property 'appendChild' of null (source: www.example.com:1)

Additional information

WizardCM commented 3 years ago

Does your document not have a <head> element?

JackobStuard commented 3 years ago

The "source" has <head> element.

WizardCM commented 3 years ago

Then the only reason it would delay adding the CSS is if the page hasn't finished loading. The code below runs OnLoadEnd()

https://github.com/obsproject/obs-browser/blob/7143a01e9499d0005129a1fbff844c8be5f16765/browser-client.cpp#L453-L459

JackobStuard commented 3 years ago

Is possible to make it faster to instantly apply CSS code? before the page starts loading? Because I see that browser load all elements but for some reason, OBS wait for a full load.

WizardCM commented 3 years ago

Not really, we wait for the page to finish loading so that we don't interrupt other code when we inject our own.

If you need custom CSS sooner, your best bet is modifying the page directly.

I'm closing this issue now as the behaviour is expected.