OBS 27.2.0 Cannot read properties of undefined (reading 'getUserMedia')

Ninja_Cookie

New Member
For privacy concerns I didn't want to include a full Log File, however here are some possibly relevant snippets from it.
More can be asked for if needed.
Code:
00:17:36.912: [obs-browser]: Version 2.17.9
00:17:36.912: [obs-browser]: CEF Version 95.0.0-MediaHandler.2464+gb58eaf2+chromium-95.0.4638.69

00:03:35.095: obs-browser: Uncaught TypeError: Cannot read properties of undefined (reading 'getUserMedia') (source: http://absolute/D:/_main/Scripts/Audio/JS/microphone.js:1)


I use a HTML file with JavaScript to do certain things based on Microphone input on the browser source, displayed through OBS using the Browser Source with the HTML file directly.
Code:
navigator.mediaDevices.getUserMedia({ audio: true, video: false }) ...
This did work fine after using --use-fake-ui-for-media-stream and --enable-media-stream however now it gives this TypeError above. Running the HTML outside of OBS with the same JS works fine and accepts this code with no error.

Is this an issue with something I am doing, and/or can I work around this issue and fix this?
Is the error even relevant and it's just failing to grant microphone permissions considering everything else in the HTML works fine?


This is my first time posting, so sorry if this isn't relevant here.
 

Ninja_Cookie

New Member
This seems to be a security permissions issue from what I can tell, which previously was not an issue in OBS.

Even though it's coming from my own machine with the direct file, it's seeing this as unsecure in version 27.2.0 of OBS.

By running the HTML file through NodeJS with CMD with "node localserver.js" with the code in "localserver.js" being:
Code:
function contentType(ext) {
    var ct;

    switch (ext) {
    case '.html':
        ct = 'text/html';
        break;
    case '.css':
        ct = 'text/css';
        break;
    case '.js':
        ct = 'text/javascript';
        break;
    default:
        ct = 'text/plain';
        break;
    }

    return {'Content-Type': ct};
}

var PATH = 'D:/ProgramFiles_NoAdmin/nodejs/node_modules'
var http = require("http");
var fs = require('fs');
var url = require("url");
var path = require("path")
var fileName = "D:/ProgramFiles_NoAdmin/nodejs/scripts/Audio/VoiceFacer.html";
const port = 8000;
    
var server = http.createServer (function (request, response) {

var dir = "D:/ProgramFiles_NoAdmin/nodejs/scripts/Audio/";
var uri = url.parse(request.url).pathname;

if (uri == "/") {
    uri = "VoiceFacer.html";
}

var filename = path.join(dir, uri);

fs.readFile(filename,
    function (err, data) {
        if (err) {
            response.writeHead(500);
            return response.end('Error loading VoiceFacer.html');
        }
                
        var ext = path.extname(filename)
        response.setHeader('content-type',contentType(ext));
        response.writeHead(200);
        response.end(data);
    });
}).listen(port);
    
console.log('Server running on localhost:' + port) ;

then creating a Browser Source in OBS that goes to "localhost:8000" correctly makes this work again.

However even though this allows me to do it, this doesn't fix the original issue, I'd much rather not have to run the file through NodeJS every time I'd want to use it, OBS should be able to handle this file securely like it did last patch.
 

Chenzo

New Member
I am not much of a GitHub person, not sure where I would put that, or what the issue exactly is, or if it's intended behaviour, or if there is just a new command I have to add to launch options.

Hey Ninja, did you ever find a solution. I'm suddenly having this problem since updating. it seems like the old command line/exe arguments aren't working anymore.

I've used both `--enable-media-stream` and `-use-fake-ui-for-media-stream` without success.

I'm using custom code in a js file that's loaded locally. it has worked fine for years until this past update. I get the feeling the arguments have changed.
 

Ninja_Cookie

New Member
Hey Ninja, did you ever find a solution. I'm suddenly having this problem since updating. it seems like the old command line/exe arguments aren't working anymore.

I've used both `--enable-media-stream` and `-use-fake-ui-for-media-stream` without success.

I'm using custom code in a js file that's loaded locally. it has worked fine for years until this past update. I get the feeling the arguments have changed.

I still just use the work-around that I posted in the comments earlier, using NodeJS to host a localhost server to host the website. Localhost runs in https where as a local file uses http which is automatically blocked for being insecure on the latest version of it, without any way to work around that in OBS still.
 

fullmontis

New Member
Same problem. Script that I have been using for a while now doesn't work anymore unless I create a secure connection
 

fullmontis

New Member
By the way, it should not necessary to use HTTPS to create a secure connection. Technically, accessing "localhost" is considered secure by Chromium, which is what is used internally by OBS (I think). So you just need to create a simple local HTTP server to do this.

If you have Python3, this is rather simple to do, just access with the terminal the local folder and type:
Code:
python3 -m http.server

And then access http://localhost/file-name.html in the browser source. Worked for me as a workaround.

I also reported the issue on GitHub here to see if I could get more info on the topic and if it is fixable (or if it has been reported before)
 

icezolation

New Member
Hey there,
using latest OBS version (27.2.4). I've been cleaning up my scenes and had to re-setup most of my browser source gadgets when I noticed that my visualizer stopped working.

The visualizer grabs the audio input of one of my virtual cables.

In the past setting --enable-media-stream and --use-fake-ui-for-media-stream launch parameters did the trick, but now all I got was the Cannot read properties of undefined when debugging.

Keeping the launch parameters, I simply changed pointing at 'Local file' browser source to URL, using file:// header:
1651222965129.png


And this did the trick.
Thought I have to throw --allow-insecure-localhost in the launch parameters but it's not needed.

Hope this helps.
 
Top