JDownloader Community - Appwork GmbH
 

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 19.09.2019, 01:16
taychive
Guest
 
Posts: n/a
Default [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
Reply With Quote
  #2  
Old 19.09.2019, 11:46
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,286
Default

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
Reply With Quote
  #3  
Old 20.09.2019, 21:01
taychive
Guest
 
Posts: n/a
Default

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.
Reply With Quote
  #4  
Old 23.09.2019, 16:22
Demongornot Demongornot is offline
JD Beta
 
Join Date: Sep 2019
Location: Universe, Local group, Milky Way, Solar System, Earth, France
Posts: 50
Default

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.
Reply With Quote
  #5  
Old 23.09.2019, 18:28
darktron
Guest
 
Posts: n/a
Default

Quote:
Originally Posted by Jiaz View Post
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?
Hi Jiaz! sorry write to you in this thread.
Could you help me with my situation? https://board.jdownloader.org/showthread.php?t=81660

thanks
Reply With Quote
  #6  
Old 24.09.2019, 02:32
taychive
Guest
 
Posts: n/a
Default

@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.
Reply With Quote
  #7  
Old 24.09.2019, 12:49
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,286
Default

@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
Reply With Quote
  #8  
Old 24.09.2019, 12:51
Demongornot Demongornot is offline
JD Beta
 
Join Date: Sep 2019
Location: Universe, Local group, Milky Way, Solar System, Earth, France
Posts: 50
Default

Quote:
Originally Posted by taychive View Post
@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?
True ! I didn't notice that it only freeze JDownloader when it is called from a button.
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:
Originally Posted by Jiaz View Post
@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
I didn't noticed it only froze the GUI, I thought the whole JDownloader was stalled, but after testing a "sleep(20000);" from toolbar and main menu bar, and indeed a test download did progress during the 20 seconds.
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.
Reply With Quote
  #9  
Old 24.09.2019, 12:53
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,286
Default

will be fixed with next core update
__________________
JD-Dev & Server-Admin
Reply With Quote
  #10  
Old 24.09.2019, 13:20
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,286
Default

@Demongornot: update will be live in 5 mins
__________________
JD-Dev & Server-Admin
Reply With Quote
  #11  
Old 25.09.2019, 02:49
taychive
Guest
 
Posts: n/a
Default

@Demongornot Thanks for pointing us in the right direction.

@Jiaz After update it is working perfect now. Thank you!
Reply With Quote
  #12  
Old 25.09.2019, 11:15
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,286
Default

Thanks for the feedback!
__________________
JD-Dev & Server-Admin
Reply With Quote
  #13  
Old 25.09.2019, 14:04
Demongornot Demongornot is offline
JD Beta
 
Join Date: Sep 2019
Location: Universe, Local group, Milky Way, Solar System, Earth, France
Posts: 50
Default

Confirmed it is fixed, thanks for that quick update !
@taychive Your welcome !
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT +2. The time now is 14:32.
Provided By AppWork GmbH | Privacy | Imprint
Parts of the Design are used from Kirsch designed by Andrew & Austin
Powered by vBulletin® Version 3.8.10 Beta 1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.