Custom Browser Dock: variable collision in LocalStorage between different docks (bug?)

Novgorod

New Member
The OBS browser engine that is used for custom browser docks allows saving data in LocalStorage, which is great to save and persist settings if the browser dock is some kind of control panel. However, the LocalStorage seems to be not isolated between different docks, so if they happen to use identical variable names, it causes a collision so that one dock overwrites a same-named variable of another dock if it was the last one to write to LocalStorage. That's obviously an issue if different docks happen to use identical generic variable names (like "theme", "color" etc.) or if you want to duplicate a particular dock where all LocalStorage variables would have identical names.

As I understand, a browser implementation must isolate LocalStorage data per domain or per document (don't know the spec exactly) because otherwise it would not only be an inconvenience but also a serious security issue. I've looked at the raw data in the levelDB used for the OBS browser's LocalStorage (plugin_config\obs-browser\Local Storage\leveldb) and each variable name has the prefix "_file://\x00\x01" immediately followed by the actual variable name used in the respective custom dock. I assume the _file:// prefix is supposed to be followed by the path to the custom browser dock html file before the actual variable name in order to implement the per-dock isolation, but there's no file path and therefore no disambiguation between docks which leads to variable name collisions.

I've only tested it with this custom dock and discovered the variable collision when I tried to duplicate it by copying and renaming the dock html file. It works when OBS is running, but only the settings of the last instance are saved and applied to all instances upon restart of OBS. That dock uses just the normal localStorage.setItem(id, value) and localStorage.getItem(id) javascript functions to access LocalStorage, so the issue is certainly not specific to that one dock. Is this behavior of the LocalStorage implementation in the OBS browser on purpose or a bug?
 
Top