libURLDownloadToFile making the UI unresponsive
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Livecode Opensource Backer
- Posts: 132
- Joined: Mon Jan 14, 2013 3:37 pm
libURLDownloadToFile making the UI unresponsive
Hi there
If I understand the LC dictionary correctly, libURLDownloadToFile is supposed to be non-blocking, but I get blocking behavior with large files.
I created an "Abort download" button to enable the user to cancel the download, but the button won't respond to mouse clicks while the download is in progress. Only after the download completes, the button catches up with the mouse clicks.
It only seems to happen with large files, i.e. files that take more than a few seconds to download.
Could this be a bug in the internet library?
If I understand the LC dictionary correctly, libURLDownloadToFile is supposed to be non-blocking, but I get blocking behavior with large files.
I created an "Abort download" button to enable the user to cancel the download, but the button won't respond to mouse clicks while the download is in progress. Only after the download completes, the button catches up with the mouse clicks.
It only seems to happen with large files, i.e. files that take more than a few seconds to download.
Could this be a bug in the internet library?
010100000110010101100001011000110110010100111101010011000110111101110110011001010010101101010100011100100111010101110100011010000010101101001010011101010111001101110100011010010110001101100101
Re: libURLDownloadToFile making the UI unresponsive
HI Ledigimate,
what platform are you experiencing this on?
What version of LC are you using?
Do you use the Community or Commercial version?
Best
Klaus
what platform are you experiencing this on?
What version of LC are you using?
Do you use the Community or Commercial version?
Best
Klaus
Re: libURLDownloadToFile making the UI unresponsive
What is happening in the rest of the script? Do you have any wait or repeat statements? Maybe you are waiting for the file to download and "blocking" the script until the test for completion is met? If so, this would need a wait "with messages" statement, to allow housekeeping time for the engine to process messages generated by other scripts like your cancel button. If not, more details are needed.
-
- Livecode Opensource Backer
- Posts: 132
- Joined: Mon Jan 14, 2013 3:37 pm
Re: libURLDownloadToFile making the UI unresponsive
Windows 10 Pro X64what platform are you experiencing this on?
version 8.1.10What version of LC are you using?
CommunityDo you use the Community or Commercial version?
010100000110010101100001011000110110010100111101010011000110111101110110011001010010101101010100011100100111010101110100011010000010101101001010011101010111001101110100011010010110001101100101
Re: libURLDownloadToFile making the UI unresponsive
What SparkOut said, we need to look at your handler(s) to be sure.
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
Re: libURLDownloadToFile making the UI unresponsive
I have a similar problem when i try to download a zip file 160 mo for 4000 files.
I often get an error "request timed out" (I used callback to see it)
No error when i download the same content file by file.
Kind regards
Jean-Marc
I often get an error "request timed out" (I used callback to see it)
No error when i download the same content file by file.
Kind regards
Jean-Marc
https://alternatic.ch
Re: libURLDownloadToFile making the UI unresponsive
Quick guess based on Jean-Marcs posting:
Maybe setting -> the socketTimeoutInterval to a higher value (default = 10000) will help?
Maybe setting -> the socketTimeoutInterval to a higher value (default = 10000) will help?
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
Re: libURLDownloadToFile making the UI unresponsive
Hi Klaus,
Thanks for suggestion.
I tried with a socketTimeoutInterval = 15000 without success, download is stopped with a time out error. (LC indy 9.01)
I will try again this night.
Kind regards
Jean-Marc
Thanks for suggestion.
I tried with a socketTimeoutInterval = 15000 without success, download is stopped with a time out error. (LC indy 9.01)
I will try again this night.
Kind regards
Jean-Marc
https://alternatic.ch
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
Re: libURLDownloadToFile making the UI unresponsive
Three tries worked as expected with socketTimeoutInterval = 10000 or 15000.
That sound like a server problem no ?
That sound like a server problem no ?
https://alternatic.ch
-
- VIP Livecode Opensource Backer
- Posts: 9802
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: libURLDownloadToFile making the UI unresponsive
If you use the callback message option the I/O should become async, allowing other messages processing such as UI handling. This is generally true of all socket operations in LiveCode.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- Livecode Opensource Backer
- Posts: 132
- Joined: Mon Jan 14, 2013 3:37 pm
Re: libURLDownloadToFile making the UI unresponsive
I've discovered that the UI's unresponsiveness is proportional to the download speed.
When I test it using a web server with Gigabit download speeds, the Abort button won't respond to being pressed until after the download completes.
When I test it using a web server with slower download speeds, the Abort button responded when pressed.
I've attached a sample stack.
When I test it using a web server with Gigabit download speeds, the Abort button won't respond to being pressed until after the download completes.
When I test it using a web server with slower download speeds, the Abort button responded when pressed.
I've attached a sample stack.
010100000110010101100001011000110110010100111101010011000110111101110110011001010010101101010100011100100111010101110100011010000010101101001010011101010111001101110100011010010110001101100101
-
- VIP Livecode Opensource Backer
- Posts: 9802
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: libURLDownloadToFile making the UI unresponsive
Thanks for posting the test stack.
Have you had a chance to test that on non-Windows systems?
When it appears to hang, does Windows rename the title bar to include "(Application Unresponsive)"?
I'm wondering if this may be related to a deeper issue LC has with not integrating with the Win OS event loop gracefully.
Have you had a chance to test that on non-Windows systems?
When it appears to hang, does Windows rename the title bar to include "(Application Unresponsive)"?
I'm wondering if this may be related to a deeper issue LC has with not integrating with the Win OS event loop gracefully.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- VIP Livecode Opensource Backer
- Posts: 2262
- Joined: Thu Feb 28, 2013 11:52 pm
- Location: Göttingen, DE
Re: libURLDownloadToFile making the UI unresponsive
Yes, libUrl is not blocking and it works here on MacOS 10.14, Win 7+10, linux (ubuntu 1604).
But LC is is not able of multitasking.
So it may be better to download your files one after the other by using "send in time", not from a repeat loop.
A few issues:
1) You should cancel *item 1 of* a line of the pendingMessages not the full line.
2) Do NOT cancel ALL pending messages. This cannot work.
Instead
Also you could use the following on openCard in case someone with an Indy license uses your stack:
But LC is is not able of multitasking.
So it may be better to download your files one after the other by using "send in time", not from a repeat loop.
A few issues:
1) You should cancel *item 1 of* a line of the pendingMessages not the full line.
2) Do NOT cancel ALL pending messages. This cannot work.
Instead
- write a download handler "ledigDownload p1,p2,p3,p4" (the p's are params you need) for one file only.
- send "ledigDownload p1,p2,p3,p4" for each single file.
Code: Select all
on cancelPendingMessages
repeat 2
repeat for each line L of the pendingMessages
if "ledigDownload" is item 3 of L then cancel item 1 of L
end repeat
end repeat
end cancelPendingMessages
Also you could use the following on openCard in case someone with an Indy license uses your stack:
Code: Select all
if there is a stack "tsNetLibURL"
then dispatch "revUnloadLibrary" to stack "tsNetLibURL" --> no problems with https
shiftLock happens