a weird bug, even if i don't know where

The place to discuss anything and everything about running your LiveCode on Android

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
rmuzzini
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 63
Joined: Mon Oct 08, 2012 11:30 am

a weird bug, even if i don't know where

Post by rmuzzini » Wed Sep 21, 2016 2:30 pm

hi all.
please, help me to identify where the bug is.

instruction:
donwload the attached stack and compile it for Android devices (note: there's a media files folder to be added as non-stack files folder before compiling the app.
run the app on android device (iOS is immune, it seems. there are other weird things, in that environment. see: http://forums.livecode.com/viewtopic.php?f=8&t=27962).
use the 4 buttons (2 "copy OK" + 2 "copy KO")
see the result

what the buttons do:
- get the files in the app embedded folder
- filter the contents to get one single file, based on its extensions
- copy it into the app documents folder

differences between "OK" and "KO" buttons:
- in "OK" btns there's an "answer" to show the list of files
- in "KO" btns the "answer" row is commented out

results:
- the "OK" btns copy the file as expected, even if NOT ALWAYS (see *note)
- the "KO" btns fail // weird…
- in the "OK" btns, anyway, the "answer" shows an empty file list… //weird weird…

tested on samsung tablet running Android 6.0.1
stack made with LC 8.1 build 14005 "Indy", on osx 10.10.5 with Android SDK rev 25.2.2 (the last one as of 20190921)
i'd like to attach also the apk binary, but it 's larger than this forum upload size limit. i can put on public dropBox if needed.

*note: if i run this test on asus tablet running Android 4.2.1 then the procedures fail in all 4 cases. //weird weird weird…

side effect: if you have to build an app which copies files on local drive, then you can't build it with LC8.
personal side effect: i currently have an app in production that needs to be upgraded for iOS 10 compatibility. it has to copy a .sqlite db on local folder. therefore i'm stuck.

additional info: yes, of course the same app built using LC7 works like a charm (see "workaround").

workaround: to get the files list, the use of the good old defaultFolder way ("the files" function) instead of new function "files(<path-to-your-folder>)" is useless. therefore, no workaround found yet.

humble request: may we have LC7 support back? please… please… please… come on… please… :-)

if someone will confirm this is a bug, with some advice about where the bug is (! i think the culprit be the "files()" function, but i can't be sure i'm absolutely right), then i'll be happy (so to speak) to file a new bug on quality.livecode.

regards.

APPENDIX
the full scripts:
OK

Code: Select all

on mouseUp
   put "result:" && copyMyFile() into fld "log"
end mouseUp

function copyMyFile
   local tMediaFileList,tPathApp,tOrigine,tDestinazione
   put specialFolderPath("resources") & SLASH & "mediatest" into tPathApp
   answer "files in embedded folder: " && files(tPathApp) //DEBUG
   put files(tPathApp) into tMediaFileList
   filter tMediaFileList with "*.png"
   put tPathApp & SLASH & tMediaFileList into tOrigine
   answer "Origin: " && tOrigine //DEBUG
   put specialFolderPath("documents") & SLASH & tMediaFileList into tDestinazione
   answer "Destination: " && tDestinazione //DEBUG
   put URL ("binfile:"& tOrigine) into URL ("binfile:"&tDestinazione)
   answer "result: " && tDestinazione //DEBUG
   return tMediaFileList
end copyMyFile

KO

Code: Select all

on mouseUp
   put "result:" && copyMyFile() into fld "log"
end mouseUp

function copyMyFile
   local tMediaFileList,tPathApp,tOrigine,tDestinazione
   put specialFolderPath("resources") & SLASH & "mediatest" into tPathApp
   //answer "files in embedded folder: " && files(tPathApp) //DEBUG
   put files(tPathApp) into tMediaFileList
   filter tMediaFileList with "*.png"
   put tPathApp & SLASH & tMediaFileList into tOrigine
   answer "Origin: " && tOrigine //DEBUG
   put specialFolderPath("documents") & SLASH & tMediaFileList into tDestinazione
   answer "Destination: " && tDestinazione //DEBUG
   put URL ("binfile:"& tOrigine) into URL ("binfile:"&tDestinazione)
   answer "result: " && tDestinazione //DEBUG
   return tMediaFileList
end copyMyFile
Attachments
test_files_stack.zip
Stack file + media folder
(23.89 KiB) Downloaded 293 times

LiveCode_Panos
Livecode Staff Member
Livecode Staff Member
Posts: 861
Joined: Fri Feb 06, 2015 4:03 pm

Re: a weird bug, even if i don't know where

Post by LiveCode_Panos » Wed Sep 21, 2016 9:43 pm

Hi rmuzzini,

This is indeed weird. My guess is that this happens because the "answer " command before calling

Code: Select all

put files(tPathApp) into tMediaFileList
pauses the execution, and for some reason this makes

Code: Select all

files(tPathApp)
to return a valid non empty list. As a workaround, you can put the call to "files(tPathApp)" in a separate handler:

Code for KO button:

Code: Select all

on mouseUp
   put "result:" && copyMyFile() into fld "log"
end mouseUp

function copyMyFile
   local tMediaFileList,tPathApp,tOrigine,tDestinazione
   put specialFolderPath("resources") & SLASH & "mediatest" into tPathApp
   --answer "files in embedded folder: " && files(tPathApp) //DEBUG
   put getfiles(tPathApp) into tMediaFileList
   filter tMediaFileList with "*.sqlite"
   put tPathApp & SLASH & tMediaFileList into tOrigine
   answer "Origin: " && tOrigine //DEBUG
   put specialFolderPath("documents") & SLASH & tMediaFileList into tDestinazione
   answer "Destination: " && tDestinazione //DEBUG
   put URL ("binfile:"& tOrigine) into URL ("binfile:"&tDestinazione)
   answer "result: " && tDestinazione //DEBUG
   return tMediaFileList
end copyMyFile

function getfiles pFolder
   return files(pFolder)
end getfiles
Best,
Panos
--

rmuzzini
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 63
Joined: Mon Oct 08, 2012 11:30 am

Re: a weird bug, even if i don't know where

Post by rmuzzini » Thu Sep 22, 2016 8:24 am

thank you for your answer, panos.
do you think it should be good to open a bug about this?

regards.

LiveCode_Panos
Livecode Staff Member
Livecode Staff Member
Posts: 861
Joined: Fri Feb 06, 2015 4:03 pm

Re: a weird bug, even if i don't know where

Post by LiveCode_Panos » Thu Sep 22, 2016 10:08 am

Hi rmuzzini,

You are welcome. Yes, I think you should file a bug report. I would expect the "files(pFolder)" function to work without restrictions. However if there are restrictions, they should be mentioned in the dictionary.

Best,
Panos
--

Kevvy
Posts: 20
Joined: Fri Jan 10, 2014 7:06 am

Re: a weird bug, even if i don't know where

Post by Kevvy » Thu Sep 22, 2016 11:46 am

I totally agree with you rmuzzini;
As a paying business customer, it is actually unacceptable that we are forced to use LC8 with so many bugs still present.

Post Reply