• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
standalone not logging in...
#1
Hi all,
I'm having difficulty with getting a standalone to use LiveCloud...

i've adapted the login set up from the 'create project' from LCM's toolkit dialog. I use the same interface/code and if successful login it navigates to another card. 

Inside LiveCode (Indy 9.6.1) this works great. 
However when building standalone this just doesn't work and no error is generated.

I've made sure all external files for the app and livecloud's required libraries are included.
In particular: Internet, tsNet, mergJSON, SSL & Encryption, as well as the app's CanelaDB toolkit folder are definitely included (I've also tried just adding the 3 subfolders of the /CanelaDB/ folder instead, but no difference)

I've added some debug code to try and figure out where the app fails in the standalone. 
Running the 'login' command below gets as far as calling cdb_auth, then nothing else happens in standalone, whereas in LiveCode it works as expected, completing the authorisation and navigating to the correct card. If i try to create a new account, nothing happens again.

The login code called by clicking 'log in' is (comments indicate what works inside LC and in Standalone)
Code:
command login
  local tInputA, tLayer, tAuthStatusA, temp
 
  if not _verifyLoginData() then
     exit login
  end if

  answer "about to send cdb_auth" //debug code -- this works in LC and Standalone

  get cdb_auth(fld "Email-input" of grp "login",fld "Password-input" of grp "login","User")
  put cdb_authStatus() into tAuthStatusA
 
  answer "Response: " & cdb_result("response")  //debug code -- does nothing in standalone; no response, no error. In LC this answers authorisation completed
 
  repeat for each key tKey in tAuthStatusA //debug code -- no response here either. In LC it answers cloud: true, local: true
     put tKey & ":" && tAuthStatusA[tKey] & return after temp
  end repeat
  answer temp
 
  if tAuthStatusA["cloud"] then
     go to card "card1" //works in LiveCode, but not standalone
  else if tAuthStatusA["local"] then
     go to card "card2" //works in LiveCode, but not standalone
  else
     answer "Error authenticating user:" && cdb_result("response")
  end if
end login

Based on this it seems like after cdb_auth, the process stalls somewhere in the standalone, as the next 'answer' debug line never fires but does inside LC.

Looking at my firewall, the app doesn't seem to be attempting to connect to the internet at all (according to Little Snitch)

What am I missing? Any help would be greatly appreciated...
  Reply
#2
Hi Stamatis,

It could be that you standalone does not have the libraries or they are in a path that does not align with the command initializeCanelaDB code the LCM provides you when you export your toolkit.

I am going to provide you the path for how this works in LiveCloud Manager and the init code we use for it.

You may need to adjust the pathing to work for the location where you placed your CanelaDB folder.

Path
/Users/mark/Desktop/Deployment/LCM Deployment/LiveCloudManager/LiveCloudManager.app/Contents/Resources/_MacOS/data/config/CanelaDB

LCM init code
command initializeCanelaDB
local tLibraryPath

wait 0 milliseconds with messages ## GIVE THE ENGINE A CHANCE TO SPIN UP
put "-" into gCDBAuthKey
set the itemDel to "/"

if the environment is "development" then
put item 1 to -2 of (the effective fileName of this stack) into tLibraryPath
else
switch the platform
case "android"
case "iPhone"
put specialFolderPath("engine") into tLibraryPath
break

case "MacOS"
put specialFolderPath("support") into tLibraryPath
put "/" & "CanelaSoftware/" & gCSManifestA["productName"] & "/" & gCSManifestA["productVersion"] & "/data" after tLibraryPath --LCM SPECIFIC PATH
break

case "Win32"
case "Linux"
put item 1 to -2 of (the effective fileName of this stack) into tLibraryPath
break
end switch
end if

put "/config/CanelaDB/libraries/" after tLibraryPath

if the environment <> "development" then
repeat for each line xLine in files(tLibraryPath)
if xLine <> "CDB_Header.lib" and xLine <> "CDB_Starter.lib" then
delete file (tLibraryPath & xLine)
end if
end repeat
else
if there is a file (tLibraryPath & ".DS_Store") then
delete file (tLibraryPath & ".DS_Store")
end if
end if

--START CanelaDB
csi_verifyLibraries tLibraryPath

try
start using stack (tLibraryPath & "CDB_Header.lib")
start using stack (tLibraryPath & "CDB_Starter.lib")

catch tError
answer "The CanelaDB SDK is missing. Please export your CanelaDB SDK again." && tError
exit to top
end try

--SET OPTIONAL LOGGING MODE
cdb_SetLogMode "message box"

cdb_loadTable "cdbCache"
end initializeCanelaDB
  Reply
#3
Thanks Mark,

I don't think that was it -- despite a couple of differences differences between the stack code in the toolkit and the code you provide, no error was being generated and nothing worked.

The differences with the toolkit code that i could see were the location of the SDK within the mac app bundle (according to your path above, the SDK is in /Contents/Resources/_MacOS/data/config/CanelaDB, whereas in my bundle it's in /Contents/Resources/_MacOS/CanelaDB. Also the stack script is slightly different - yours uses specialFolderPath("support"), whereas the stack script is specialFolderPath("resources") in case "MacOS"

Changing all of the above to match your script above made no difference whatsoever.
Then i decided to see if the startup script was even being triggered, by adding an answer dialog to state what environment was being detected in the preOpenStack script.
And then the login worked!

I wondered if the wait 0 milliseconds with messages needed a larger value, but removing the debug code didn't make a difference - it still works now.
I can only presume this is some kind of odd gremlin/corruption in my stack which has somehow ironed itself out. 

I'm now faced with other unexpected behaviour with the standalone (i've set the database to be local and sync from cloud on start up but this isn't happening now in standalone - only works inside liveCode) -- but that's a struggle for another day Smile
  Reply
#4
I figured the issue was around the init code. Code should work reliably every time. The reason for it working after adding a dialog is uncertain. I have some other thoughts that may or may not be of any use.

Are you running on Mac Catalina or Big Sur? Apple Notarization may be a factor.


Code:
case "MacOS"
put specialFolderPath("support") into tLibraryPath
put "/" & "CanelaSoftware/" & gCSManifestA["productName"] & "/" & gCSManifestA["productVersion"] & "/data" after tLibraryPath --LCM SPECIFIC PATH
break

You can see that we are accounting for that in the LCM startup with specialFolderPath("support"). Our startup code will not work well in standalones on systems running Mac 10.14 or newer. The best we can do is document how to modify the path to work with how people will deal with notarization. The database needs write permission. Mac developers will need to store their database outside of their standalone going forward. We chose to store our data in the 'Application Support'.
  Reply
#5
Thanks Mark,
I'm on Catalina, haven't made a move to big sur just yet - hadn't figured on notarisation, you may well be right - but on the other hand, the app shouldn't run at all if that were the case?

This attempt was an interim build to test something with the local database.
At present i sync cloud -> local on login... bit of a delay starting up, but subsequent actions much quicker. But on quit, the local DB seems to disappear - is that meant to be the case or am i doing something wrong?


It very much makes sense not to store the database inside the app bundle, and places like app support, documents or preferences seem a much better place for the SDK to reside. I had asked that exact question a while back anticipating this kind of issue but think that question just fizzled out and i didn't pursue it...

I know the documentation section on this will be updated at some point, but in the mean time, is the general idea that on first run the app will copy the SDK folder to a writeable destination? Not sure LCM does that at present, i could find no CanelaSoftware  folder in either my /Library/Application Support/ or my ~/Library/Application Support/ folders, but it there is a copy of this inside the LCM app bundle at   /Contents/Resources/_MacOS/data/config/CanelaDB.
Not sure where the  specialFolderPath("support") is used?

Anyway will keep working on the app inside LiveCode and will revisit this at some point later...
  Reply
#6
If you have not codesigned or notarized, you are probably not running write permission issues locally.

When the sync takes place, do you see the changes happening both locally and in the cloud? If so, we can rule out that the libraries are not loaded.
Your local data is automatically saved to disk for you. Do you have a cdb_loadTable (https://docs.livecloud.io/LoadTable/) in your code? It is possible that your data is not being loaded into memory on startup of your app. We used to do it automatically, but we received enough feedback indicating that developers wanted full control when the data was to be loaded. In our apps, we do not always load all the tables for a database in a single moment.

When you are ready to ship your app, you will want to have all your data and possibly code running from another location. We do both so we can auto-update the code. You will not be able to modify your code or data if stored in the bundle once the bundle is codesigned.

When we release our notarized version, you will find everything that is in resource folder moved over to the app support folder. This was managed not by LiveCloud, but from our SpiceKit libraries. Our SK libraries manage our auto-update and licensing tech.
  Reply
#7
(11-12-2020, 11:36 PM)mark_talluto Wrote: If you have not codesigned or notarized, you are probably not running write permission issues locally.

When the sync takes place, do you see the changes happening both locally and in the cloud? If so, we can rule out that the libraries are not loaded.
Your local data is automatically saved to disk for you. Do you have a cdb_loadTable (https://docs.livecloud.io/LoadTable/) in your code? It is possible that your data is not being loaded into memory on startup of your app. We used to do it automatically, but we received enough feedback indicating that developers wanted full control when the data was to be loaded. In our apps, we do not always load all the tables for a database in a single moment.

When you are ready to ship your app, you will want to have all your data and possibly code running from another location. We do both so we can auto-update the code. You will not be able to modify your code or data if stored in the bundle once the bundle is codesigned.

When we release our notarized version, you will find everything that is in resource folder moved over to the app support folder. This was managed not by LiveCloud, but from our SpiceKit libraries. Our SK libraries manage our auto-update and licensing tech.

Thanks Mark,
cdb_loadTable was probably the missing ingredient - i'll check that out but from your reply i'm guessing that will do the trick.
For now still working on the app in LC as there is still a huge amount of work to do and very little spare time to do it in! 
I'll experiment with storing the data in a safe/writable place, that's definitely going to be needed... thank you.
  Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)