JS engine can't parse class private methods
Magistone opened this issue · 2 comments
Operating System Info
Windows 10
Other OS
No response
OBS Studio Version
27.1.3
OBS Studio Version (Other)
No response
OBS Studio Log URL
https://obsproject.com/logs/2VzpKM_-cgb4287C
OBS Studio Crash Log URL
No response
Expected Behavior
Expected the JS engine to parse the js code successfully
Current Behavior
When the OBS browser JS engine tries to parse the source it logs an error in console at #privateMethod()
with the error unexpected token (
Private fields nor public methods are not affected
Steps to Reproduce
- Use sample code from the official documentation (copy bellow)
class ClassWithPrivateField {
#privateField;
}
class ClassWithPrivateMethod {
#privateMethod() {
return 'hello world';
}
}
class ClassWithPrivateStaticField {
static #PRIVATE_STATIC_FIELD;
}
class ClassWithPrivateStaticMethod {
static #privateStaticMethod() {
return 'hello world';
}
}
- add include the js file with the code above to an html file as
<script src="theFile.js"></script>
- load the created html file in OBS
- Open devtools in your browser, select the loaded file. In console there will be error message
Uncaught SyntaxError: Unexpected token
on the line with#privateMethod()
Anything else we should know?
The files in the provided log are custom code, currently unavailable to the public. However, I did confirm that the example given with the copy of syntax
code triggers the bug as well.
Per https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Private_class_fields#browser_compatibility, private class methods are not supported by the CEF version used in OBS. Work is underway to update CEF but it is a large undertaking.
Status on the upgrade can be followed here: obsproject/obs-studio#3853