Max number of resources

I get another runtime error when I try your game on an Android;

W/defold  ( 7463): WARNING:GRAPHICS: 0:11: S0024: Symbol 'tan' redeclared
W/defold  ( 7463): 0:26: L0001: Symbol 'tan' can't be referenced as a variable
W/defold  ( 7463): 0:26: L0001: Symbol 'tan' can't be referenced as a variable
W/defold  ( 7463): 0:27: L0001: Symbol 'tan' can't be referenced as a variable
W/defold  ( 7463): 0:27: L0001: Symbol 'tan' can't be referenced as a variable
W/defold  ( 7463): 0:28: L0001: Symbol 'tan' can't be referenced as a variable
W/defold  ( 7463): 0:31: L0001: Symbol 'tan' can't be referenced as a variable
W/defold  ( 7463): 0:31: L0001: Symbol 'tan' can't be referenced as a variable
W/defold  ( 7463): 0:32: L0001: Symbol 'tan' can't be referenced as a variable
W/defold  ( 7463): 0:32: L0001: Symbol 'tan' can't be referenced as a variable
W/defold  ( 7463): 0:33: L0001: Symbol 'tan' can't be referenced as a variable
W/defold  ( 7463):
W/defold  ( 7463): WARNING:RESOURCE: Unable to create resource: /assets/materials/flux.vpc
W/defold  ( 7463): WARNING:RESOURCE: Unable to create resource: /assets/materials/flux.materialc
W/defold  ( 7463): WARNING:RESOURCE: Unable to create resource: /game/shots/selectionRoom/selection_generated_9_generated_0.modelc
W/defold  ( 7463): WARNING:RESOURCE: Unable to create resource: /game/shots/selectionRoom/selection_generated_9.goc
E/defold  ( 7463): ERROR:GAMEOBJECT: Could not instantiate game object from prototype /game/shots/selectionRoom/selection_generated_9.goc.
E/defold  ( 7463): ERROR:GAMEOBJECT: Child not found: /jack_flux
W/defold  ( 7463): WARNING:RESOURCE: Unable to create resource: /game/shots/selectionRoom/selection.collectionc
E/defold  ( 7463): ERROR:GAMESYS: The collection /game/shots/selectionRoom/selection.collectionc could not be loaded.

Which points to an error in the flux.vp shader, where you have named a uniform tan which might be a reserved keyword (for the tan() function). You should be able to rename this uniform to u_tan or something similar (and also change the material and scripts where tan otherwise is set), and it should solve this error.


This might not be the same issue you are having, but it certainly something to investigate. (I’m going to give it a few minutes and fix it locally here just to see if I encounter the other issue you were describing.)

2 Likes

After fixing the shader issues I was able to reproduce the original issue.

However, I’m not sure if it is a bug or not. Looking at the web profiler on a desktop build we can see that there are ~700 resources loaded in idle (at the game screen).

My guess is that Android is a bit slower loading/unloading resources, which could mean that on Android both the the selection and play collections are in memory at the same time?

In any case, I’m not going to investigate this one further until we have a simpler repro case. I would suggest you up the “max_resources” entry in the Resource category of game.project for now and let us know if you are having similar issues in the future. Sounds good? :slight_smile:


And to do a quick explanation of your initial question “How is the “number of resources” defined?”;
In Defold we try to preallocate memory in places where the game developer know how much will be needed at runtime, instead of having to do runtime memory allocation. This is essentially to optimise performance and memory usage. There are some “sane” defaults, but of course it’s hard to set a default value that will work for every possible game.


And btw, the game looks really pretty! Great job! :smiley:

4 Likes

@sergey.lerg, @sven thank you so much for your help!

I will increase the max number of resources and try. However, I am curious how you see that there are ~700 resource “loaded in idle”? I was told to count the number of rows in the web profiler to get the number of resources used, and this is ~70 in the game screen.

1 Like

Ah! And thank you very much for the issue about “tan” in the shader! This was not raised by my android device nor by the mac. A really precious help!

1 Like

This is how it looks for me when running one level;


I zoomed out to 25% and there still is a scrollbar, at this frame there were 673 rows.

Also, if you have the time I would suggest you take a look at both the resources list, and the collection tree to the left. Check if there is something strange, maybe something is loaded that shouldn’t be etc. :+1:

2 Likes

And indeed also for me the list is long as in your screenshot. Probably in my previous check I was looking at a sample in a different step in the game.

I doubled the max resource number to 2048, just to have a quick test. And it worked!

So, thank you again! Probably the garbage collector (may I guess?) is slower on the Android device and the count is passing over 1024 while the game screen is loading.

I will surely check carefully the list and the tree. I have already done this check for texture using the Mac openGL profiler and everything looks good; but this is only about video memory.

Again, my thanks to all you there at Defold and the people on the forum. It is a pleasure to work with such a community.

Ciao, Rocco.

5 Likes