iOS app has begun opening very slowly
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
iOS app has begun opening very slowly
I have been working on an iOS app for a good while. It has recently begun opening very slowly on my iPhone 6+
It used to open inside of 3 seconds, but now takes more than 11-12 seconds from splash screen to full opening.
It includes 5 fairly large text data files (around 4+ MB each) but opened fast with all of them before. I hadn't made any major changes in the code, only slight debugging just before the problem cropped up. Returning to an earlier version of the app (pre-debugging) restored the speed of opening, but of course, has the bugs. The app size is under 56 MB on my Mac disk.
I am using LC Indy 9.0.1 and Xcode 9.4.1 (9F2000).
Has anyone else had a similar issue?
It used to open inside of 3 seconds, but now takes more than 11-12 seconds from splash screen to full opening.
It includes 5 fairly large text data files (around 4+ MB each) but opened fast with all of them before. I hadn't made any major changes in the code, only slight debugging just before the problem cropped up. Returning to an earlier version of the app (pre-debugging) restored the speed of opening, but of course, has the bugs. The app size is under 56 MB on my Mac disk.
I am using LC Indy 9.0.1 and Xcode 9.4.1 (9F2000).
Has anyone else had a similar issue?
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
Re: iOS app has begun opening very slowly
Hi rcmills
I remembrer that Jacqueline said that a short preopenstack with a send in time is better than a long preopenstack message. I tested it with success.
You may make your preopenstack shortest as possible and use a send in time for next step
Something like that:
Best regards
Jean-Marc
I remembrer that Jacqueline said that a short preopenstack with a send in time is better than a long preopenstack message. I tested it with success.
You may make your preopenstack shortest as possible and use a send in time for next step
Something like that:
Code: Select all
on preOpenStack
if the environment <> "mobile" then
set the loc of this stack to the screenloc
end if
send "doAfterPreOpenStack" to me in 1 milliseconds
end preOpenStack
on doAfterPreOpenStack
--...
end doAfterPreOpenStack
Jean-Marc
https://alternatic.ch
Re: iOS app has begun opening very slowly
Thanks Jean-Marc,
I tried it, and the relevant code now reads:
Unfortunately, it seems that the change has only shaved off maybe a second or two of opening time.
I tried it, and the relevant code now reads:
Code: Select all
on preOpenStack
set acceleratedRendering of this stack to true
send "doAfterPreopenStack" to me in 1 milliseconds
end preOpenStack
on doAfterPreopenStack
lock screen
if the environment is "mobile" then
insert the script of button "Common" of this card into back
insert the script of button "Profile" of this card into back
local tOrientations
put "portrait,portrait upside down,landscape left,landscape right" into tOrientations
mobileSetAllowedOrientations tOrientations
set the fullscreenmode of this stack to "noScale"
updateProfiles -- adjust profiles for actual device screen size
fwmobCreateNativeScroller the long id of fld "book text"
fwmobResizeNativeControls
end if
get setUpFieldSizes(the rect of this cd)
get readDataFile(false)
unlock screen
end doAfterPreopenStack
Re: iOS app has begun opening very slowly
@rcmills: Has the content of the text files, or what readDataFile() does, changed since earlier versions which are quicker?
Re: iOS app has begun opening very slowly
Not to any significant degree. The 5 text files are identical to prior to the speed change, and are not read by readDataFile(), though they are loaded with the app during the start up, I assume. Only one (at a time) of them is read in here (the 4 lines beginning with:
get "/mb.version." & fld "version label" & ".txt").
There is a data.txt file with around 5 or 6 lines of data which restore the last state of the app. The code of the data reading subroutine is here, and is also not changed since before the speed change.
Thanks.
get "/mb.version." & fld "version label" & ".txt").
There is a data.txt file with around 5 or 6 lines of data which restore the last state of the app. The code of the data reading subroutine is here, and is also not changed since before the speed change.
Code: Select all
function readDataFile flag
put getDataFilePath("data.txt") into tFile
put URL tFile into tData
repeat with i = 1 to 5
if line i of tData is empty
then
put "Gen 1 1" into line 1 of tData
put "KJV" into line 2 of tData
put 15 into line 3 of tData
put "Arial" into line 4 of tData
put 0 into line 5 of tData
end if
end repeat
put word 1 of tData into tBook
put word 2 of tData into tChapter
put line 2 of tData into fld "version label"
get "/mb.version." & fld "version label" & ".txt"
put "file:/" & specialfolderpath("engine") into sFolder
put (sFolder & it) into tFile
put URL tFile into bibleText
get line 3 of tData
if it < 8 then get 8
set the textSize of fld "book text" to it
set the textFont of fld "book text" to line 4 of tData
get showBookChap(tBook,tChapter,true) -- true means don't choose verse
set the vScroll of fld "book text" to line 5 of tData
if the environment is "mobile" then
fwmobCreateNativeScroller the long id of fld "book text"
fwmobResizeNativeControls
end if
put "file:/" & specialFolderPath("documents") & "/bibleAppDocs/searchHistory.txt" into tFileName
if the environment is "mobile"
then put "file:/" & specialFolderPath("documents") & "/searchHistory.txt" into tFileName
if fld "history" is empty then put URL(tFileName) into fld "history"
saveDataFile
end readDataFile
Re: iOS app has begun opening very slowly
@rcmiills: Okay so if the data files haven't changed (which wasn't relevant anyway), and the startup code hasn't changed then:
- Has the stackfile changed? e.g. has it got bigger, more objects added
- Has the version of LC you are using changed?
- Has the OS version on your device changed?
I'm guessing it must be something in the stackfile itself which has changed - otherwise you wouldn't observe the faster speed with previous versions
- Has the stackfile changed? e.g. has it got bigger, more objects added
- Has the version of LC you are using changed?
- Has the OS version on your device changed?
I'm guessing it must be something in the stackfile itself which has changed - otherwise you wouldn't observe the faster speed with previous versions
Re: iOS app has begun opening very slowly
I finally reverted to the last faster opening file, and slowly re-debugged, checking at each step on the simulator for opening times. I have re-acheived a (hopefully) bug free state, and still have a good (around 1 second) opening time. The file size is around 237 KB. The slow loading file was around 296 KB, though I am not sure why it was so much larger. I can't recall putting enough new code in to make that difference, but must assume I was more efficient in the second debugging.
Many thanks for all the advice
Many thanks for all the advice
Re: iOS app has begun opening very slowly
You no longer need to manually include the common and profile library scripts in LC 9 like you are doing. That was something that I had to do before the IDE was updated to support those inclusions in mobile. You also probably are going to want to verify the fullscreenmode since it may not work as expected on another size device.
Brian Milby
Script Tracker https://github.com/bwmilby/scriptTracker
Script Tracker https://github.com/bwmilby/scriptTracker
Re: iOS app has begun opening very slowly
Thanks, Brian.
Does that mean I don't need to include the devControls substack, either?
Does that mean I don't need to include the devControls substack, either?
Re: iOS app has begun opening very slowly
It isn’t needed in the built app but does make setting up the profiles easier in the IDE. Depending on how complex the UI is, it may be easier to just write the resizeStack handler to account for orientation and size changes manually.
Here is another mobile demo that has a manual resizeStack handler. It doesn’t change things based on orientation directly, but does have some code that adjusts based on width. It uses neither GM nor PM.
https://github.com/bwmilby/mobileDemo
Here is another mobile demo that has a manual resizeStack handler. It doesn’t change things based on orientation directly, but does have some code that adjusts based on width. It uses neither GM nor PM.
https://github.com/bwmilby/mobileDemo
Brian Milby
Script Tracker https://github.com/bwmilby/scriptTracker
Script Tracker https://github.com/bwmilby/scriptTracker
Re: iOS app has begun opening very slowly
Thanks very much!