#1
|
|||
|
|||
[Event Scripter] Using 'alert' causes JD2 to freeze
Hi, a few weeks ago i was playing with the event scripter and learning how things worked. I got been busy with another project and put this on the side for a bit but now i have time again.
When i go to run my previous test code, that worked before, it causes JD2 to freeze. I have to then forcefully restarted the program to use it again. I removed code line by line until i figured out the what was causing the freezing. It was the line with 'alert' i had put in there. With it removed the code completes successfully. So now i make a one line script from the alert example in the help menu, but this too causes JD2 to freeze. Code:
alert(JD_HOME); Is this a bug or how can i troubleshoot this on my installation? Thanks |
#2
|
||||
|
||||
I'm sorry but I can't reproduce the freeze/issue.
What event-trigger do you use? does it also freeze when you hit 'Test Run' ? What OS are you using? Does the alert dialog show up?
__________________
JD-Dev & Server-Admin |
#3
|
|||
|
|||
I am running JD2 from a docker image created by jlesage **External links are only visible to Support Staff**...
It is based on Alpine 3.9 with an in browser display for local control. The event trigger is 'Toolbar Button Press' As soon as I press the assigned toolbar button, JD2 stops. I can move my mouse but nothing is highlighted or selectable. The red blinking animations of the other icons also stop. At this point I must restart the docker container to use JD2 again No it does not freeze when i use the Test Run button. The dialog opens correctly. |
#4
|
|||
|
|||
I also noticed that, you'll need to uncheck the "Synchronous execution of script" option of your script.
Apparently when this is checked, JDownloader stop all tasks to run the script and wait for the script to be done before resuming, so if you have a script that do x action on a download, when triggered, everything will freeze until x action have been accomplished, generally script don't take long so it probably went unnoticed, but when you create like an idiot like me and cause an infinite loop or forget to set loop exit condition, it become quite noticeable. And when showing an alert box, the same happen, except that I think it also freeze the part of the code that handle the alert box itself and button activation, rendering it impossible to click with cursor or use enter key, it freezing JDownloader for ever. Simply create a new script with only "sleep(5000);" as code, check "Synchronous execution of script" and run it, you'll be unable to do anything for 5 seconds as the whole interface is now frozen. I guess, when this is checked, the script run through the same process as the rest of JDownloader, completely stopping it, but JDownloader being the one who handle the alert box as it basically run Javascript code as an interpreter, it might get stalled while invoking the alert box and stuck as it can't call handlers to close it because it is already stuck waiting for finishing handling the alert box, which need its closing handle etc etc. I think JDownloader team should consider sandboxing the script with synchronous execution, stopping some process (the downloads, link grabber, crawler etc, but not the interface, the API caller or the Javascript handler) as the script is executed and allowing to auto exit the sandbox if the script stall the main program for too long, meaning infinite loop, faulty codes and alert box won't cause JDownloader to be permanently stuck until the process is terminated manually. Also if someone make a script that trigger through interval, show an alert box, set it as synchronous and activate it and that JDownloader remember the script being enabled before freezing, the person is now good to find how to delete manually the script as JDownloader will now freeze at every launch. Edit : Also a "task manager" who show currently running scripts, their name and ID, their starting date/time, their last activation date/time, if it is currently running and since when, their trigger mode and parameters (interval time) and if they are synchronous or not, and if not how many instances are currently running. With of course the possibility to stop them individually, I remember when discovering Javascript the Event Scripter, I made mistakes causing infinites loops making JDownloader slow to respond and using a lot of CPU, I wish I could have simply kill those script execution rather than force JDownloader to close and open it again. Last edited by Demongornot; 23.09.2019 at 16:34. |
#5
|
|||
|
|||
Quote:
Could you help me with my situation? https://board.jdownloader.org/showthread.php?t=81660 thanks |
#6
|
|||
|
|||
@Demongornot
Thank you, that work around worked. I agree with your explanation but there is just one thing that doesn't make sense. Why does the test run not care or matter if the synchronous execution is enabled or disabled? Does starting the script from the toolbar make it a part of the GUI process cause freezing where as the test button is running the script as an a separate/independent process? @darktron Please don't hijack threads. You topic has nothing to do with the issue being discussed here. It's rude to the thread starter. Secondly, it was the weekend. I'm sure the Jiaz will reply to your thread when he is caught up and looks into your problem. |
#7
|
||||
|
||||
@Demongornot: The "Synchronous execution of script" should not freeze the GUI and I have to look into this. This is a bug and not a feature
__________________
JD-Dev & Server-Admin |
#8
|
|||
|
|||
Quote:
I tried with other trigger such as interval or a download stopped, sleep and alert don't cause JDownloader to freeze. It totally throw away my previous theory. You might be right. Quote:
I thought it was normal that "Synchronous execution of script" put on hold all operations so that it give the time for the script to do its thing and then resume everything. Last edited by Demongornot; 24.09.2019 at 13:16. |
#9
|
||||
|
||||
will be fixed with next core update
__________________
JD-Dev & Server-Admin |
#10
|
||||
|
||||
@Demongornot: update will be live in 5 mins
__________________
JD-Dev & Server-Admin |
#11
|
|||
|
|||
@Demongornot Thanks for pointing us in the right direction.
@Jiaz After update it is working perfect now. Thank you! |
#12
|
||||
|
||||
Thanks for the feedback!
__________________
JD-Dev & Server-Admin |
#13
|
|||
|
|||
Confirmed it is fixed, thanks for that quick update !
@taychive Your welcome ! |
Thread Tools | |
Display Modes | |
|
|