Skip to content

Conversation

@deemonrider
Copy link

Description

This new feature adds a getItemTransform function to the browser source to retrieve its own transformation information
(position, scale, rotation, alignment, bounds, crop, and dimensions) with the default basic permission READ_OBS.

Motivation and Context

I was really shocked to discover that this feature doesn't exist. Thinking about what information a browser should be able to read out, this would be my first thought:

  1. Missing essential information: window.outerWidth / screen.width or similar tells you the size of the browser source itself BUT not if a user messed up the aspect ratio or scaled down the source via transforming. Currently, the only way to get this information is by using the websocket. This leads to the next big issue:
  2. HTTPS websites can't access a non-secure Websocket: When providing browser sources to streamers, they are usually all served via HTTPS— The issue? Mixed Content. When serving the Browser Source via HTTPS, we can't access the non-secure websocket. This means I would need to host a separate HTTP overlay just to be able to read out how my source is configured. Serving a browser source without HTTPS is no longer acceptable and will discourage users, as HTTP is widely considered insecure.
  3. Least Privilliges: Additionally, WebSockets grant me full rights to do whatever I want—technically. So as a user, you wouldn't really want to have that enabled just to read out some basic information. This implementation is read-only and can't harm anyone but provide essential value.

I can provide further reasons if needed, but I think the case is clear.

How Has This Been Tested?

Environment: Windows 11 x64, OBS Studio 31.1.2 (build 104)

  • I've used the buildin obs debugging tool to access the console and compare the output to the settings I've changed of the browser source and then called in the console:
window.obsstudio.getItemTransform(function (transform) {
    console.log(transform);
})
  • I've tested the permission behavior handling if the user removes all permissions of the browser source -> returns null like the other functions.

For example, take a look at the screenshot and the distorted aspect ratio. With this function, I could either display an error message informing the user not to stretch the browser source, or alternatively, automatically adjust the aspect ratio internally to prevent it from breaking.

image

Types of changes

New feature (non-breaking change which adds functionality)
Documentation (a change to documentation pages)

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.

@gxalpha
Copy link
Member

gxalpha commented Aug 23, 2025

This approach using obs_scene_find_source falls apart once you have multiple scene items of the source.

@deemonrider
Copy link
Author

This approach using obs_scene_find_source falls apart once you have multiple scene items of the source.

I hadn’t considered that, thanks for pointing it out. I’ve reworked the implementation and opened a new PR, so I’ll close this one.
#500

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants