TheQwertiest / foo_spider_monkey_panel

foobar2000 component that allows to use JavaScript to create CUI/DUI panels
https://theqwertiest.github.io/foo_spider_monkey_panel/
MIT License
274 stars 21 forks source link

Script reloading during package manager usage and popups bugs #210

Open regorxxx opened 1 year ago

regorxxx commented 1 year ago

WshShell.Popup instances keep running after closing package manager and SMP panel, which turns into weird bugs since the panel gets reloaded after closing the later.

For ex. this popup fires as soon as the package manager is closed: image

But then the script is reloaded when the SMP panel window is closed again. That behavior is totally prone to errors when using packages, since the script is loaded multiple times while the window is opened.

The problem comes when popups are present. They are spanned multiple times (since the script keeps reloading everytime you click ok). And the window doesn't close while there is a popup box asking for user input.

When you close one of the popups, since it's trying to reference a script variable no longer present (due to reloading), it crashes. plm3

In other words, if the user keeps trying to close the SMP window before closing the popups.... it may well get 10 copies of the same popup and 10 crashes of the same panel in a row.

regorxxx commented 1 year ago

All this makes popup calling totally incompatible with package loading, since it will always break the panels on first installation unless the user is pointed to first close all popups.

regorxxx commented 1 year ago

Attached the recording of another user with this problem.

https://user-images.githubusercontent.com/83307074/235798157-0b6896f9-f8f4-4fd0-8c25-48dc7126aced.mp4

https://hydrogenaud.io/index.php/topic,120979.msg1026417.html#msg1026417

regorxxx commented 1 year ago

As shown here with irony, there is no way to stop script execution at that point: https://hydrogenaud.io/index.php/topic,120979.msg1026438.html#msg1026438

const infoPopup = WshShell.Popup('This script has been installed as a package.\nBefore closing the \'Spider Monkey Panel configuration window\' all popups must be closed, take your time reading them and following their instructions.\nAfterwards, close the SMP window.', 0, window.Name, popup.info + popup.ok);
if (getPropertiesValues(properties, 'plm_').filter(Boolean).length === 0) {
    throw new Error('READ THE POPUPS AND STOP CLICKING ON BUTTONS WITHOUT READING!!!\nOtherwise TT, aka GeoRrGiA-ReBorN\'s master, will try\nto kill you with their bad jokes.\n\nReally, read the popups and make our lives easier.\n\nThanks :)');
}

I check after the popup if the properties are accessible (they don't) and I'm able to identify when the panel has been reloaded before closing a popup, but at that point there is no way to do anything but throwing. There is no window.stop(), or any way to simply stop running anything more or silently crash the script instance (and continue with the main one).

regorxxx commented 1 year ago

So essentially did something like this: https://hydrogenaud.io/index.php/topic,120979.msg1027526.html#msg1027526 plm

Forcing the user to click a button after installing the script (and that would start the standard loading of the script, with popups, etc.). And since the mouse callbacks are disabled while SMP windows are opened, that's fine. Anyway this is just a workaround.