Just discovered that one of my programs after an update now used extremely long time to start up. This was the first time compiled with the new apk compiler version.
First just a white screen for a minute or so, then the bcpic is loaded and then a few more minutes before the main screen is fully loaded.
I had done quite a few changes in my code so I tried reverting piece by piece to find what new caused this slowdown.
Then I just stripped down the code to a minimum to test, but still it was dead slow.
Turns out it is the usage of GetDircectoryEntry that causes this.
I have 3 linked directories with containing 371 files, about 4.5MB in total.
Adding these files to Asset and using GetAsset instead the app loads in two seconds.
Just for debugging I did test to keep the directory links in my code (but still use GetAsset). Then the app start with a white screen for 30 seconds, then the bgpic and the rest of the main screen loads as normal.
Very slow GetDirectoryEntry
Re: Very slow GetDirectoryEntry
...unfortunately these crap these days should be
Debugged first by total disabling antivirus craps..
It has high probabilty...
Debugged first by total disabling antivirus craps..
It has high probabilty...
Christos
Re: Very slow GetDirectoryEntry
Nor sure if I follow you here. You suggest that the app run slow on Android because of antivirus software?
I did try to set google protect to pause, but it is still is significantly slower when using GetDirecoryEntry vs GetAsset
- airsoftsoftwair
- Posts: 5959
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: Very slow GetDirectoryEntry
Very difficult to say what's going on without an example that I can test here. Have you got an MCVE?
Re: Very slow GetDirectoryEntry
I did some troubleshooting along the way making this MCVE.
It looks like a combined case of things that provoke the slowdown.
First use this script on windows to create some files
Here is the MCVE using directory entry:
Here is the same script, but using asset. That should load much faster on Android.
Try the above first to see if you can replicate what I experience.
To complicate this even more, I did find that if replacing the pdf plugin with the old polybios plugin in this MCVE, then the slowdown is gone.
However, that does not help for my full script. There it is slow with both pdf and polybios unless I swicth to Asset.
It looks like a combined case of things that provoke the slowdown.
First use this script on windows to create some files
Code: Select all
@DISPLAY {Title = "DirectoryEntry", ScaleMode = #SCALEMODE_AUTO, Orientation = #ORIENTATION_LANDSCAPE, FitScale = True, SmoothScale = True, HideTitleBar = True}
MakeDirectory("testfiles")
CreateBrush(1, 1920, 1080, #GRAY)
SaveBrush(1, "testfiles/bgpic.png", {Format = #IMGFMT_PNG})
For i = 1 To 1000
f$ = "testfiles/"..i..".png"
CreateGradientBrush(i, 1200, 800, #LINEAR, GetRandomColor(), GetRandomColor())
SaveBrush(i, f$, {Format = #IMGFMT_PNG})
Next
Code: Select all
@DISPLAY {Title = "DirectoryEntry", ScaleMode = #SCALEMODE_AUTO, Orientation = #ORIENTATION_LANDSCAPE, FitScale = True, SmoothScale = True, HideTitleBar = True}
@REQUIRE "pdf"
@DIRECTORY 1, "testfiles"
LoadBGPic(1, GetDirectoryEntry(1, "bgpic.png"))
DisplayBGPic(1)
For i = 1 To 100
LoadBrush(i, GetDirectoryEntry(1, i..".png"))
Next
Repeat
DisplayBrush(Rnd(100)+1, Rnd(1720), Rnd(880))
Wait(2)
Until IsLeftMouse() = True
Code: Select all
@DISPLAY {Title = "DirectoryEntry", ScaleMode = #SCALEMODE_AUTO, Orientation = #ORIENTATION_LANDSCAPE, FitScale = True, SmoothScale = True, HideTitleBar = True}
@REQUIRE "pdf"
LoadBGPic(1, GetAsset("testfiles/bgpic.png"))
DisplayBGPic(1)
For i = 1 To 100
LoadBrush(i, GetAsset("testfiles/"..i..".png"))
Next
Repeat
DisplayBrush(Rnd(100)+1, Rnd(1720), Rnd(880))
Wait(2)
Until IsLeftMouse() = True
To complicate this even more, I did find that if replacing the pdf plugin with the old polybios plugin in this MCVE, then the slowdown is gone.
However, that does not help for my full script. There it is slow with both pdf and polybios unless I swicth to Asset.
- airsoftsoftwair
- Posts: 5959
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: Very slow GetDirectoryEntry
Thanks a lot for the detailed information and the MCVE! All the information you provided allows me to make an educated guess. I think this new feature introduced in version 2.0 of the PDF plugin is responsible for your problem:
This means that all your LoadBrush() calls will first go through the PDF plugin which is probably slowing down things a lot. Polybios didn't have this feature so there was no slowdown. Also, the PDF plugin won't kick in when loading assets which is why there is no slowdown with assets either. So to fix the issue I think you just have to tell LoadBrush() to NOT use the PDF plugin, i.e. like this:
I haven't tested your code myself but judging from what you described I think that the new image loader adapter introduced in version 2.0 is the cause for your problem...
Code: Select all
- New: The plugin can now also load PDF pages directly into brushes using @BRUSH and LoadBrush(); pass
the "Page" user tag to @BRUSH or LoadBrush() to specify the number of the page to load; there is also
a "Transparent" user tag which can be used to specify whether or not the plugin should fill the PDF
page with a white background; if "Transparent" is FALSE (the default), the page will automatically
be filled with a white background, otherwise it will be made transparent; finally, there is a user
tag named "Password" which can be used to specify the password for encrypted PDFs
Code: Select all
LoadBGPic(1, GetDirectoryEntry(1, "bgpic.png"), {Loader = "inbuilt"})
DisplayBGPic(1)
For i = 1 To 100
LoadBrush(i, GetDirectoryEntry(1, i..".png"), {Loader = "inbuilt"})
Next
Re: Very slow GetDirectoryEntry
Thanks for your input.
That does make a huge difference for this particular MCVE, so your guess was correct.
I find that a bit odd though that it would use the pdf loader as default instead of the inbuilt one.
But this did not solve the issue completely for my full script, because I got that delay even when using polybios.
I did find another thing that made a huge difference for my script.
If I remove this line from the top of my script
Then it loads about 5 seconds slower than when using GetAsset.
If I use the Asset method it loads in just a couple of seconds with out removing that line.
Also, if I add that font line into the MCVE above there will be a notable delay even for that small script.
Like this:
That does make a huge difference for this particular MCVE, so your guess was correct.
I find that a bit odd though that it would use the pdf loader as default instead of the inbuilt one.
But this did not solve the issue completely for my full script, because I got that delay even when using polybios.
I did find another thing that made a huge difference for my script.
If I remove this line from the top of my script
Code: Select all
@FONT 1, "Times New Roman", 52, {Engine = #FONTENGINE_INBUILT}If I use the Asset method it loads in just a couple of seconds with out removing that line.
Also, if I add that font line into the MCVE above there will be a notable delay even for that small script.
Like this:
Code: Select all
@DISPLAY {Title = "DirectoryEntry", ScaleMode = #SCALEMODE_AUTO, Orientation = #ORIENTATION_LANDSCAPE, FitScale = True, SmoothScale = True, HideTitleBar = True}
@REQUIRE "pdf"
@DIRECTORY 1, "testfiles"
@FONT 1, "Times New Roman", 52, {Engine = #FONTENGINE_INBUILT}
LoadBGPic(1, GetDirectoryEntry(1, "bgpic.png"), {Loader = "inbuilt"})
DisplayBGPic(1)
For i = 1 To 100
LoadBrush(i, GetDirectoryEntry(1, i..".png"), {Loader = "inbuilt"})
Next
Repeat
DisplayBrush(Rnd(100)+1, Rnd(1720), Rnd(880))
Wait(2)
Until IsLeftMouse() = True