SQLite Images and Standalone Issues

Creating desktop or client-server database solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Stewart Lynch
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 23
Joined: Sun Jul 13, 2008 7:39 pm

SQLite Images and Standalone Issues

Post by Stewart Lynch » Sat Aug 06, 2016 11:58 pm

I have an app that works perfectly in development. I store and retrieve images to a SQLite database.
No issues at all.
However, when I build the runtime version, the data stored as the image data is completely corrupted and the application fails horribly.

Has anyone else experienced this?

Using LiveCode 8.1.0 dp2

MaxV
Posts: 1579
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: SQLite Images and Standalone Issues

Post by MaxV » Mon Aug 08, 2016 3:17 pm

Try with livecode 7
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

Ormente
Posts: 28
Joined: Wed Nov 12, 2014 7:47 pm
Location: Near Mâcon, France

Re: SQLite Images and Standalone Issues

Post by Ormente » Tue Aug 09, 2016 1:15 pm

You can also try to base64Encode your data before storing them, and use base64Decode to restore the original (binary) data.

Stewart Lynch
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 23
Joined: Sun Jul 13, 2008 7:39 pm

Re: SQLite Images and Standalone Issues

Post by Stewart Lynch » Tue Aug 09, 2016 7:10 pm

No improvement with livecode 7. Same issue.
What is most disappointing is that it works flawlessly in development mode. It is just when I compile to runtime mode that it fails.
Not sure what to do now. I will try base64Encode/deCode but I am not particularly hopeful on this.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9801
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: SQLite Images and Standalone Issues

Post by FourthWorld » Tue Aug 09, 2016 9:54 pm

Stewart Lynch wrote:What is most disappointing is that it works flawlessly in development mode. It is just when I compile to runtime mode that it fails.
Is the db external included in your Standalone Builder settings?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Mikey
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 755
Joined: Fri Jun 27, 2008 9:00 pm

Re: SQLite Images and Standalone Issues

Post by Mikey » Wed Aug 10, 2016 2:13 pm

Definitely make sure you encode/decode the data, and even though SQLL is very forgiving on datatypes, make sure your datatype is BLOB.

Stewart Lynch
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 23
Joined: Sun Jul 13, 2008 7:39 pm

Re: SQLite Images and Standalone Issues

Post by Stewart Lynch » Wed Aug 10, 2016 11:52 pm

Everything I try works just fine in development. I can use base64 encoding or not.
The problem arises when I build to a standalone.
I know that the dbexternal is included in the runtime because I can access the data that was stored during the development process. However, as soon as I build it, the storing and retrieval of the image data is corrupted.
I m about to give up and abandon the project as I have spent far too much time on this.
As I said, very disappointing.

Mikey
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 755
Joined: Fri Jun 27, 2008 9:00 pm

Re: SQLite Images and Standalone Issues

Post by Mikey » Thu Aug 11, 2016 12:47 am

So did you use base64encode/decode in standalone, or not?

Stewart Lynch
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 23
Joined: Sun Jul 13, 2008 7:39 pm

Re: SQLite Images and Standalone Issues

Post by Stewart Lynch » Thu Aug 11, 2016 9:33 pm

Yes, I used base64encode/decode in standalone with same unsuccessful results.
Again, why does it work in development but not in standalone?

Mikey
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 755
Joined: Fri Jun 27, 2008 9:00 pm

Re: SQLite Images and Standalone Issues

Post by Mikey » Thu Aug 11, 2016 10:22 pm

Well, that's what we're trying to help you figure out. Please excuse the beginner questions, I don't know you. The standalone is on what platform? Are you sure that whatever script you are running isn't silently dying before it achieves? LC scripts, if they fail, when compiled, will do so silently. It's annoying, but it's the world we live in. Without seeing your code and a sample, it's all guessing from this end.

Compiling anything, especially something from a very forgiving scripting environment, can and does sometimes lead to different behavior. LC isn't the only tool that suffers from this malady.

Ormente
Posts: 28
Joined: Wed Nov 12, 2014 7:47 pm
Location: Near Mâcon, France

Re: SQLite Images and Standalone Issues

Post by Ormente » Fri Aug 12, 2016 8:34 am

It could be interesting to know if the problem comes from writing or reading.

Can you read, with the standalone, images stored by the live environment ?
Can you read, in the live environment, images stored by the standalone ?
And with an other app (a DB manager, for example, there are some free for SQLite), what do you see written by your app (in both modes) ?
And if you put an image in your DB with that tool, can your app read it ? in wich mode ?

You get the idea...

Stewart Lynch
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 23
Joined: Sun Jul 13, 2008 7:39 pm

Re: SQLite Images and Standalone Issues

Post by Stewart Lynch » Sat Aug 13, 2016 10:12 pm

The problem is definitely though writing in the standalone.
If I update the database via the runtime version, I can read it OK via the runtime version. However, as soon as I update the second (cropped image) via a snapshot and update the database, the cropped image gets corrupted somehow when updating the table.
The development version works fine. Updates to the cropped image are saved correctly
http://www.screencast.com/t/zq7izNrz
I have taken out all extraneous code from my app and built this simple example to demonstrate the problem.
Watch this video to see what I am trying to accomplish and showing how the runtime fails.


If someone else can test this stack I have attached and then build as a runtime and get the same result then I will know I am not going crazy. If it is a bug, I am not sure how even to report it.
Image Store.livecode.zip
This is the stack that I used in this demo
(3.6 KiB) Downloaded 386 times

Ormente
Posts: 28
Joined: Wed Nov 12, 2014 7:47 pm
Location: Near Mâcon, France

Re: SQLite Images and Standalone Issues

Post by Ormente » Sat Aug 13, 2016 11:19 pm

Thanks for all the information/stack/movie.

I gave a look at it, and i suspected the problem came from a lack of "metadata" about the cropped image stored in the DB. Somehow, the standalone could not figure out what to do with the retrieved data : If i saved the main image in the cropped field of the DB, it came back perfectly, but not the cropped one. This one was missing something, and that was not due to the writing/retrieving process since the other one go thru the same.

So, i gave a look at the doc and found that the "export snapshot" (on the CropIt button) can have a format specified, like AS JPEG. Simply adding this solved the issue for me. Give it a try.

For some mysterious reason the interactive livecode is more forgiving and try harder to figure out what to do with the data... but specifying a format seems to ensure the correct image header is included in the binary data, so LC know what it is when it get it back (ie how to decode it to a picture).

Stewart Lynch
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 23
Joined: Sun Jul 13, 2008 7:39 pm

Re: SQLite Images and Standalone Issues

Post by Stewart Lynch » Sun Aug 14, 2016 2:18 am

Ormente, you are a life saver. Having been away from LiveCode for quiet some time now (I have been developing iOS and MacOS apps in Swift for the past couple of years), I am just getting back in to it and should have checked out the documentation.

I am only using LiveCode now for Desktop apps as I am more comfortable using Xcode and Swift for developing iOS apps.

Thank you for taking the time to follow this thread and offer a solution. Very much appreciated. Merci beaucoup mon ami.

Ormente
Posts: 28
Joined: Wed Nov 12, 2014 7:47 pm
Location: Near Mâcon, France

Re: SQLite Images and Standalone Issues

Post by Ormente » Sun Aug 14, 2016 8:50 am

Je t'en prie Stewart, c'était un plaisir.

Thanks Stewart, you're welcome. It's allways a pleasure to help (and i learn a lot in the process).

It's also nice i was able to reproduce the issue and fix it... on windows.
If i wanted to make a (very unfair) joke i would say that it helps a lot that livecode is really consistently bugged. :lol:
But, seriously, it was very very cool to be able to do crossplatform troubleshooting.

Post Reply

Return to “Databases”