When loading a great amount of dynamic components, the app crashes

Hi Koders.
I have an app for yoga practice. Each yoga pose (asana) of each sessions is configured with a Dynamic card view that has inside several elements, labels, images and arrangements, all of them dynamic elements:
imagen

Each session has a dictionary where the keys are the order of each element and the values are the code for each asana and the session is loaded with a “for each order in list”, where this list is the keys of the dictionary. The value of each singular element is stored in a TinyDB using a code and are loaded in a certain order so each asana looks like in the previous image.

But when the session is quite large, the app crashes when loading it. My device has 4Gb of RAM and sometimes it crashes, sometimes not, I guess that with less RAM the problem will be worse.

How can I solve this problem?
I tried changing the “for each” method to a iterating process where the first item of the order list is deleted each time and when the list lenght is 0 the process stops, but it crashes either.

Any idea will be welcome.
Thanks in advance!

Use logcat to find out more about that runtime error

Taifun

1 Like

Use this extension load fast list no lag , no crash

1 Like

Use RecyclerView in such cases to avoid errors

credit to @zainulhassan

We have tested with more than 13k from gsheet and it works like charm

1 Like

I will try this. Thanks.

It looks good, but it makes me to rebuild almost half of the blocks of the app because everything is done with Yusuf Cihan dynamic components. I will look into it.

I read that the extension builds elements so fast because it renders only the elements visible in the screen. In my app you can change the order of the elements, delete any or add new ones, does the extension work nice with this issues?
For example, I can move a component five positions up or down and then automatically there is a scroll to the new position of the moved item, will this work with this extension?
Thanks.

Dynamic component will gets slower whenever there is huge data. I have not tried the method you said with this extension. Let me try it later and will let you know. I hope add and dele possible but moving from place to place … …

If you wanna Dyna component to load faster to some extent then do not use Dyna creation for the whole procedure ,just use procedure of procedure

But element created with this extension will be compatible with Yusuf Cihan Dynamic components? I mean, this block:
blocks

will still work even if the id and the element itself is created with this extension?

Yeah sure . See the link attached in my previous reply. Where I would have created multiple buttons with this extension. Once created multiple buttons upon clicking the selective button it will pop up with I’d of the button

In bind you must set up id for every component using the tag. That’s all

1 Like

Then I only have to change the way that elements are created (using this extension) and not rebuild the rest of blocks that use Yusuf Cihan Dynamic components, is that correct?

Ok, so I will give it a try and see.
Thanks!

EDIT: Not good for me. This extension is good when all the components are generic, but I can’t use the order to asign the id, for example, because every element have a specific id and I don’t know how manage the data. Plus order can be changed when editing the session and other elements could be added or deleted, so I think it won’t work right for me.

Hi. I’m not sure if I did it right, but this is what I’ve done:

adb logcat -c (this is suppossed to clean the log)

Start the app and open the large session. Three attempts it loaded right, at the fourth, the app crashed. Then:
adb logcat *:E -d > logcat.txt

(I guess this writes the file with only the errors)
I hope you can find something there.
Thanks for your help.
logcat.txt (83.5 KB)

here is the error

11-18 20:26:25.181 28861 28861 E ActivityThread: Activity io.kodular.jcmarquitecto.Yd54_Loading.Screen1 has leaked IntentReceiver com.google.appinventor.components.runtime.Network$1@6e80cd that was originally registered here. Are you missing a call to unregisterReceiver()?
11-18 20:26:25.181 28861 28861 E ActivityThread: android.app.IntentReceiverLeaked: Activity io.kodular.jcmarquitecto.Yd54_Loading.Screen1 has leaked IntentReceiver com.google.appinventor.components.runtime.Network$1@6e80cd that was originally registered here. Are you missing a call to unregisterReceiver()?
11-18 20:26:25.181 28861 28861 E ActivityThread: 	at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:1821)
11-18 20:26:25.181 28861 28861 E ActivityThread: 	at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:1552)
11-18 20:26:25.181 28861 28861 E ActivityThread: 	at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1762)
11-18 20:26:25.181 28861 28861 E ActivityThread: 	at android.app.ContextImpl.registerReceiver(ContextImpl.java:1728)
11-18 20:26:25.181 28861 28861 E ActivityThread: 	at android.app.ContextImpl.registerReceiver(ContextImpl.java:1716)
11-18 20:26:25.181 28861 28861 E ActivityThread: 	at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:736)
11-18 20:26:25.181 28861 28861 E ActivityThread: 	at com.google.appinventor.components.runtime.Network.<init>(SourceFile:65)
11-18 20:26:25.181 28861 28861 E ActivityThread: 	at java.lang.reflect.Constructor.newInstance0(Native Method)
11-18 20:26:25.181 28861 28861 E ActivityThread: 	at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
11-18 20:26:25.181 28861 28861 E ActivityThread: 	at gnu.expr.PrimProcedure.apply(PrimProcedure.java:272)
11-18 20:26:25.181 28861 28861 E ActivityThread: 	at gnu.mapping.CallContext.runUntilDone(CallContext.java:234)
11-18 20:26:25.181 28861 28861 E ActivityThread: 	at gnu.mapping.CallContext.runUntilValue(CallContext.java:298)
11-18 20:26:25.181 28861 28861 E ActivityThread: 	at gnu.kawa.reflect.Invoke.applyN(Invoke.java:209)
11-18 20:26:25.181 28861 28861 E ActivityThread: 	at gnu.mapping.ProcedureN.apply2(ProcedureN.java:39)
11-18 20:26:25.181 28861 28861 E ActivityThread: 	at io.kodular.jcmarquitecto.Yd54_Loading.Screen1.$define(Screen1.yail:10254)
11-18 20:26:25.181 28861 28861 E ActivityThread: 	at com.google.appinventor.components.runtime.Form.onCreateFinish(SourceFile:483)
11-18 20:26:25.181 28861 28861 E ActivityThread: 	at com.google.appinventor.components.runtime.Form.onCreate(SourceFile:403)
11-18 20:26:25.181 28861 28861 E ActivityThread: 	at android.app.Activity.performCreate(Activity.java:8130)
11-18 20:26:25.181 28861 28861 E ActivityThread: 	at android.app.Activity.performCreate(Activity.java:8110)
11-18 20:26:25.181 28861 28861 E ActivityThread: 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1343)
11-18 20:26:25.181 28861 28861 E ActivityThread: 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3782)
11-18 20:26:25.181 28861 28861 E ActivityThread: 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3975)
11-18 20:26:25.181 28861 28861 E ActivityThread: 	at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
11-18 20:26:25.181 28861 28861 E ActivityThread: 	at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
11-18 20:26:25.181 28861 28861 E ActivityThread: 	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
11-18 20:26:25.181 28861 28861 E ActivityThread: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2377)
11-18 20:26:25.181 28861 28861 E ActivityThread: 	at android.os.Handler.dispatchMessage(Handler.java:106)
11-18 20:26:25.181 28861 28861 E ActivityThread: 	at android.os.Looper.loopOnce(Looper.java:233)
11-18 20:26:25.181 28861 28861 E ActivityThread: 	at android.os.Looper.loop(Looper.java:344)
11-18 20:26:25.181 28861 28861 E ActivityThread: 	at android.app.ActivityThread.main(ActivityThread.java:8204)
11-18 20:26:25.181 28861 28861 E ActivityThread: 	at java.lang.reflect.Method.invoke(Native Method)
11-18 20:26:25.181 28861 28861 E ActivityThread: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:589)
11-18 20:26:25.181 28861 28861 E ActivityThread: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1071)

probably there is an error in your blocks?
however let me suggest you to follow the advice by @Still-learning and use a RecyclerList

Taifun

1 Like

Sorry, can you tell me exactly where it is? Maybe the first two lines?

Where do I should start to look? What can be the problem, if you have any idea?

Yes, I guess I have to struggle a bit with this extension and find the way to solve the problem.

Thanks again for your help anyway.

Do not worry , we will help you in this regard. But before that pls share us some of your db as screenshot so that it could be easy for us suggest

1 Like

Sorry, what is db?

Database.
You want to create layout according to database or input only?

I don’t have a database, the data is stored in TinyDB for each component. When an element is created, the specific value is loaded from TinyDB, using as tag the id of the main element attached to a word. For example, for the name of the asana, the tag for the TinyDB value will be “01004Name” where 01 is the code for the session, 004 the code for the asana and Name the kind of data to be loaded.

The elements are created with Dynamic component, then assigned the properties with a dictionary and assigned the value with TinyDB, one after the other with a “for each” method, but with this extension the elements seems to be created all at the same time and assigned the values after that, and I don’t know exactly how to handle that, but I can intuit it can be done, but I have to try and spend more time on it.

If you don’t mind, I’ll ask you concrete questions as the doubts appears.
Thanks.

you are always welcome. i will send you sample file tm. I believe our approach can be easily achievable with that extension…

Can you PM me for some questions?

what about asking here in the public community so everyone can learn?
Taifun