Open soapdog opened 3 years ago
Not all items in the assets folder can be downloaded at runtime. Fonts for example need to be there from the start.
An important quality-of-life refactor would be to have some routines that execute during savingMobileStandalone
to generate the assets zip and file manifest.
This would require us to break assets into two folders with the same folder structure. One folder will be bundled with the application, the other will become the zip that is downloaded at runtime.
Both end up copied to documents
upon launching the first-time use module.
Alright! You got the assets/fonts !
I've been diving deep into the application initialization code. It is even more convoluted than I remember. I just noticed that apparently init_LoadStackFilesFromConfiguration
is not being called. This is a mistake, we list the stack files in the configuration JSON but they are not being added to the stackFiles
property of Siva-Siva-App.livecode stack.
Apparently the stackFiles
property of Siva-Siva-App.livecode stack has been set by hand. I will need to do a clean up and relink/rework some functions there.
Today I have worked on creating better logging routines for the application, making sure the initialization calls the init_LoadStackFilesFromConfiguration
, moving most of the assets to assets-external
folder, starting a little Development Tools stack.
Most of the time were spent working with the initialization scripts and logging.
AT THE MOMENT THIS BRANCH CAN'T BE USED WITH MOBILE, DON'T TRY. That is because the new log
, logging
functions don't have their mobile equivalent yet and they'll fail on a mobile device or simulator. That is work for tomorrow.
On the Desktop, Siva Siva App will write a siva-siva.log
to the root folder of the repo. Look at this example showing the initialisation of the application:
INIT : behavior_InitSivaSivaProject (preOpenStack:51) -> ---- init_AppConfiguration ---- (+0)
INIT : behavior_InitSivaSivaProject (init_AppConfiguration:74) -> finish loading json (+48)
INIT : behavior_InitSivaSivaProject (init_AppConfiguration:80) -> start loading libraries (+14)
INIT : behavior_InitSivaSivaProject (init_LoadLibraries:201) -> loading aagNetworkTracer (+1)
INIT : behavior_InitSivaSivaProject (init_LoadLibraries:201) -> loading lib_MobileControls (+1)
INIT : behavior_InitSivaSivaProject (init_LoadLibraries:201) -> loading lib_SivaSiva (+9)
INIT : behavior_InitSivaSivaProject (init_LoadLibraries:201) -> loading lib_SivaSivaBookmark (+8)
INIT : behavior_InitSivaSivaProject (init_LoadLibraries:201) -> loading lib_SivaSivaBrowser (+9)
INIT : behavior_InitSivaSivaProject (init_LoadLibraries:201) -> loading lib_SivaSivaMedia (+9)
INIT : behavior_InitSivaSivaProject (init_LoadLibraries:201) -> loading lib_SivaSivaPortal (+9)
INIT : behavior_InitSivaSivaProject (init_LoadLibraries:201) -> loading lib_Dialogs (+9)
INIT : behavior_InitSivaSivaProject (init_LoadLibraries:201) -> loading lib_timeUtilities (+8)
INIT : behavior_InitSivaSivaProject (init_LoadLibraries:201) -> loading lib_CustomControls (+9)
INIT : behavior_InitSivaSivaProject (init_LoadLibraries:201) -> loading lib_UIHandlers (+10)
INIT : behavior_InitSivaSivaProject (init_LoadLibraries:201) -> loading lib_DevelopmentTools (+10)
INIT : behavior_InitSivaSivaProject (init_LoadLibraries:201) -> loading aagDataStorageLib (+1)
INIT : behavior_InitSivaSivaProject (init_LoadLibraries:201) -> loading aagDBLib (+9)
INIT : behavior_InitSivaSivaProject (init_LoadLibraries:201) -> loading jnanam (+10)
INIT : behavior_InitSivaSivaProject (init_LoadLibraries:201) -> loading model_SivaSiva (+23)
INIT : behavior_InitSivaSivaProject (init_LoadLibraries:201) -> loading model_SivaSivaConfig (+2)
INIT : behavior_InitSivaSivaProject (init_LoadLibraries:201) -> loading model_SivaSivaFiles (+1)
INIT : behavior_InitSivaSivaProject (init_LoadLibraries:201) -> loading model_SivaSivaLog (+2)
INIT : behavior_InitSivaSivaProject (init_LoadLibraries:201) -> loading model_SivaSivaPrefs (+1)
INIT : behavior_InitSivaSivaProject (init_LoadLibraries:201) -> loading model_SivaSivaJournal (+1)
INIT : behavior_InitSivaSivaProject (init_LoadLibraries:201) -> loading model_SivaSivaTracking (+2)
INIT : behavior_InitSivaSivaProject (init_LoadLibraries:201) -> loading model_Stories (+1)
INIT : behavior_InitSivaSivaProject (init_AppConfiguration:84) -> end loading libraries (+2)
INIT : behavior_InitSivaSivaProject (init_AppConfiguration:87) -> start StoreControlsIds (+1)
INIT : behavior_InitSivaSivaProject (init_AppConfiguration:89) -> end StoreControlsIds (+1)
INIT : behavior_InitSivaSivaProject (init_AppConfiguration:92) -> start CreateLocalFolders (+0)
INIT : behavior_InitSivaSivaProject (init_AppConfiguration:94) -> end CreateLocalFolders (+1)
INIT : behavior_InitSivaSivaProject (init_AppConfiguration:96) -> start Fonts (+1)
INIT : behavior_InitSivaSivaProject (init_AppConfiguration:98) -> end Fonts (+29)
INIT : behavior_InitSivaSivaProject (init_AppConfiguration:108) -> open Portal Stack (+8)
INIT : behavior_InitSivaSivaProject (init_AppConfiguration:134) -> ---- time spent initializing app: 251ms ---- (+1)
It shows which object
and which handler
and line
called the log function. It also shows how long it took to reach that log command since the previous log command in milliseconds. This helps when you're trying to detect timing issues between parts of the code.
I have a new idea: the fact is that "assets.gz" is running on to server, it will download on install the app.
I created a branch "fontsUsage"
I put under the handler "init_Fonts"
command init_Fonts start using font file (path_HomeLocal() & "fonts/NotoSans-Regular.ttf") start using font file (path_HomeLocal() & "fonts/NotoSans-Medium.ttf") start using font file (path_HomeLocal() & "fonts/NotoSans-Bold.ttf") start using font file (path_HomeLocal() & "fonts/NotoSans-BoldItalic.ttf") start using font file (path_HomeLocal() & "fonts/NotoSans-Black.ttf") start using font file (path_HomeLocal() & "fonts/NotoSans-BlackItalic.ttf") end init_Fonts
rather than
start using font file (path_Assetl() & "fonts/NotoSans-Regular.ttf")
and all the fonts worked in the stacks!
in "lib_SivaSiva"
function path_Assets local tPath put path_HomeLocal() into tPath put "assets/" after tPath return tPath end path_Assets
function path_Assets local tPath put path_Documents() into tPath put "assets/" after tPath return tPath end path_Assets
And it will work across all the stacks. We just have to download that "assets'gz" on the "Siva-Siva-Portal.livecode" and we put "assets/" into the Documents folder!
Siva Siva App is getting too large. We need to trim down the bundle size by externalising the content of the assets folder into a downloadable bundle that is retrieved upon first use of the app.