Storage / file component performance issues

Hi there

I began using AppInventor recently and this is the first time i am trying to store files.
My goal is to stream data over BLE into my phone (Samsung Galaxy S7 on Android 8.0), save the data into a file on the phone while acquiring the stream and when the file has been saved i would like to use the phone's WiFi capabilities to send that file to a remote server.

To benchmark the performance of the file block i came up with this basic logic:


Until now i tried "App" and "Legacy" scope, but neither meet my expectations.

I am facing 2 issues:

  1. It takes several hours until i can actually find the file in m phone's storage (do not have an sd card installed but am not sure if that is a must?)
  2. When the file finally gets accessible, its content is completely unreliable. I mean if i was trying to log data for just 10 seconds at 100Hz the file will just contain a variable amount (some hundreds) of values, but i never find all the 1000 values in the file.

My questions are:

  • Are these expected findings?
  • If not, what might i be doing wrong?
  • Which storage method shall i choose to capture my incoming data stream?

I do not see any BLE blocks in your screenshot to receive the data?
Why are you using 2 clocks?
You only can append text to a file if the file already is there...
Starting with the SDK30 release the file component stores files in the ASD - application specific directory (file scope = App), this because Android introduced restrictions in accessing files and directories...
Unbenannt
You might want to append the data to a global variable rather than using a file to avoid accessing the file system (which slows things down)...
Generally a timer interval of 10ms might be too frequent... remember: the blocks also need some time to execute... try 100ms and if you got that running, then try a shorter timer interval...

Taifun

@Taifun
Thanks for the reply!

I do not see any BLE blocks in your screenshot to receive the data?

Yes, because i have broken down my logic. As i do not have any idea how a mobile phone would perform, i wanted to benchmark different features separated first.

Why are you using 2 clocks?

One was for simulating the data rate of my board, the other clock is to stop the process after the desired time has elapsed.

I was shocked how poorly my original code performed. Since then i modified my code and now i am inserting data in a list first and save the list into a file only once at the end.


File_and_list_benchmark.aia (3.6 KB)

Meanwhile i also made a more complex app that uses list to catch incoming BLE data (20 byte MTU using RegisterForBytes logic, 20 byte packets are aggregated on the board side). Am a bit surprised to see that an octa-core Exynos 8890 chip running Android can not keep up with a single core ARM M4 board programmed in C++: the phone can receive 500 bytes per second only for about 20 secs then it begins to heat up, cuts back performance and then it can not maintain the data rate... That is even without plotting data on canvas or saving to a file.

I just wonder if Android is that inefficient or AppInventor is not meant for demanding applications?
Is there any framework that would run SIGNIFICANTLY faster than AppInventor or this performance is about the best one can get on a mobile phone?