[BUG] Scripts with type="module" are ignored #226

Closed
opened 2020-05-03 21:09:36 -05:00 by Rosuav · 11 comments
Rosuav commented 2020-05-03 21:09:36 -05:00 (Migrated from github.com)

Platform

Operating system and version:
OBS Studio version: 25.0.2+ (built from git) on Debian Linux

Expected Behavior

JavaScript in <script type=module> blocks should be executed.

Current Behavior

JavaScript in such blocks is ignored.

Steps to Reproduce

  1. Create a browser source referencing https://rosuav.github.io/Ratigan/cutdown
  2. The JS should create a list item (saying "visible"). This can be confirmed in a regular browser.

Additional information

This script file is not using any module-specific features (eg imports), and should be executed just the same as if the type were omitted.

The issue does not seem to occur on Windows, but I have not confirmed this.

<!-- READ THIS FIRST --> <!-- The OBS Studio GitHub issue tracker is **ONLY** to be --> <!-- used for reporting Bugs that have replication steps. --> <!-- You can post Feature Requests here: https://ideas.obsproject.com/ --> <!-- Get help for Support Issues here: https://obsproject.com/help --> <!--- Provide a general summary of the issue in the Title above --> ## Platform <!-- Please fill out the following information about your bug report. --> <!-- If you are on Linux and installed using a package, please list the package type. --> Operating system and version: OBS Studio version: 25.0.2+ (built from git) on Debian Linux ## Expected Behavior JavaScript in `<script type=module>` blocks should be executed. ## Current Behavior JavaScript in such blocks is ignored. ## Steps to Reproduce 1. Create a browser source referencing https://rosuav.github.io/Ratigan/cutdown 2. The JS should create a list item (saying "visible"). This can be confirmed in a regular browser. ## Additional information This script file is not using any module-specific features (eg imports), and should be executed just the same as if the type were omitted. The issue does not seem to occur on Windows, but I have not confirmed this.
Fenrirthviti commented 2020-05-03 21:14:02 -05:00 (Migrated from github.com)

Can confirm it works fine on Windows 10.

Can confirm it works fine on Windows 10.
Fenrirthviti commented 2020-05-03 21:18:11 -05:00 (Migrated from github.com)

Not sure if it helps anything, but on windows the event is triggered twice when showing/hiding the source for some reason: visibility

Not sure if it helps anything, but on windows the event is triggered twice when showing/hiding the source for some reason: ![visibility](https://pub.rachni.com/img/obs64_2020-05-03_21-17-40.png)
Rosuav commented 2020-05-03 21:21:48 -05:00 (Migrated from github.com)

That's very curious. I've seen some other situations where the event double-fires, though (even in browsers), so I've no idea what the cause is. (If you want more info about the events themselves, try https://rosuav.github.io/Ratigan/comfy which establishes a socket connection to Twitch as well, allowing a bit of external interaction; it also gives more detailed info about the event timings and such.) That's tangential to this issue, which is that the script isn't even being run at all, if the type is module.

That's very curious. I've seen some other situations where the event double-fires, though (even in browsers), so I've no idea what the cause is. (If you want more info about the events themselves, try https://rosuav.github.io/Ratigan/comfy which establishes a socket connection to Twitch as well, allowing a bit of external interaction; it also gives more detailed info about the event timings and such.) That's tangential to this issue, which is that the script isn't even being run at all, if the type is module.
WizardCM commented 2020-05-03 22:02:40 -05:00 (Migrated from github.com)

The double-fire definitely isn't expected behaviour, but it's largely because we have to fake the event due to our current CEF build (and a few around it) having a broken visibility API. As long as it's reporting accurately, that should be fine.

If you're not seeing it fire, it's likely because you have Projector, Properties, Interact or Filters opened for the source. Due to the way OBS treats visibility, they are technically "always visible". Ideally you instead want to hook into the obsSourceActiveChanged event on the window/document instead. This will always give you a real status on whether the browser is visible in the stream/recording, regardless of previews visible. More info on the available JS bindings here.

The double-fire definitely isn't expected behaviour, but it's largely because we have to fake the event due to our current CEF build (and a few around it) having a broken visibility API. As long as it's reporting accurately, that should be fine. If you're not seeing it fire, it's likely because you have Projector, Properties, Interact or Filters opened for the source. Due to the way OBS treats visibility, they are technically "always visible". Ideally you instead want to hook into the `obsSourceActiveChanged` event on the window/document instead. This will always give you a real status on whether the browser is visible in the stream/recording, regardless of previews visible. More info on the available [JS bindings here](https://github.com/obsproject/obs-browser#js-bindings).
Rosuav commented 2020-05-03 22:25:57 -05:00 (Migrated from github.com)

Curious. Why is it different on Linux and Windows?

Curious. Why is it different on Linux and Windows?
WizardCM commented 2020-05-03 22:26:48 -05:00 (Migrated from github.com)

In a local build on Ubuntu with CEF 3809, the visibility API behaves identical to Windows, with the side effects mentioned in my earlier post. Which version of CEF are you building with?

In a local build on Ubuntu with CEF 3809, the visibility API behaves identical to Windows, with the side effects mentioned in my earlier post. Which version of CEF are you building with?
Rosuav commented 2020-05-03 22:47:40 -05:00 (Migrated from github.com)

Ah! Even more interesting. And I'm not sure, how would I check?

Ah! Even more interesting. And I'm not sure, how would I check?
WizardCM commented 2020-05-03 22:48:32 -05:00 (Migrated from github.com)

Navigate to chrome://version and it'll be listed along the top.

Navigate to `chrome://version` and it'll be listed along the top.
Rosuav commented 2020-05-03 22:57:18 -05:00 (Migrated from github.com)

Gotcha. It's CEF 3.3029.1613.g22354a9 but I've no idea where I got that from. I think it was brought in automatically as part of the OBS build.

Gotcha. It's CEF 3.3029.1613.g22354a9 but I've no idea where I got that from. I think it was brought in automatically as part of the OBS build.
WizardCM commented 2020-05-03 22:59:02 -05:00 (Migrated from github.com)

Then that's likely why. We only support 3770 and 3809 officially, 3029 is way too old. Please verify with a 3809 build from Spotify.

Then that's likely why. We only support 3770 and 3809 officially, 3029 is way too old. Please verify with a 3809 build from [Spotify](http://opensource.spotify.com/cefbuilds/index.html).
Rosuav commented 2020-05-04 00:24:13 -05:00 (Migrated from github.com)

Hmm. I don't know what's going on, but everything I try to do to update CEF results in the browser being badly broken - either not rendering at all, or rendering in some way that is completely unreadable. But I'm going to close this issue, because the actual reported bug appears to simply be "CEF is too old". And quite frankly, the issues with updating it are not worth my effort at the moment. I'm reverting to the working one.

Hmm. I don't know what's going on, but everything I try to do to update CEF results in the browser being badly broken - either not rendering at all, or rendering in some way that is completely unreadable. But I'm going to close this issue, because the actual reported bug appears to simply be "CEF is too old". And quite frankly, the issues with updating it are not worth my effort at the moment. I'm reverting to the working one.
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-obsproject/obs-browser#226
No description provided.