Android Question I would like some advices on developing the B4A WebGL library

max123

Well-Known Member
Licensed User
Longtime User
Hi all.

Some days ago I released the B4J WebGL Library.
To use that the user have to download the THREEJS distribution and put it on the develop machine inside DirData.
Happen that any B4J project can refer this, so the distribution is shared between more projects without have to copy it on every project. This works very well.

Now I'm at good point to develop the B4A WebGL library, but I not found a way to do this that works the same way.
On every project the user have to zip the THEEJS distribution (only substantial parts) and put the zip file to the Asset folder.
After this the library will check for existence of it in DirInternal and if it does not yet exist (only a first time) will be copied and unzipped to DirInternal.

This process is quite tedious as the zipped THREEJS distribution, even removing useless files, is several Megabytes (about 50MB) and you have to copy the zip file into Assets of each new project, even have more projects that use WebGL will consume more space on Android device, so the final app will be big.

What I need is a common THREEJS distribution on Android, where any new app created (that use WebGL library) can access it shared.
I know that with Android restrictions this is not possible, but I want to search a better solution to this.

May is there a way to use External Storage and use a common folder that more apps (that have permission) can access as shared folder ?

The problem here is even that External Storage is very, very slow API, I had a lots of problems with it's speed, 1/10 and less speed that old File API, expecially when list files.

Another big problem is that a common THREEJS distribution should be served over HTTP.

At this point I'm a bit out of ideas ...

Someone have some advices I can evalutate ?

Many Thanks.
 
Last edited:

byz

Active Member
Licensed User
Upvote 0

max123

Well-Known Member
Licensed User
Longtime User
Hi @byz, many thanks for advices.

1. You can copy the new version of three.js from an external folder or root directory to the app-specific folder, so that at least the public version is updated.
This can only useful for the final user to have threejs updated, but this can even break the app in long period because threejs will continue to change.
What I mean is for developer side, where developer have to copy on every new project the three.js zip file.
I'm not sure if an app can create an external storage folder, then other apps can acquire the permission to access the already created folder from the other app in a way that more apps can share the same folder. Eventually after this we can just copy the distribution from here to DirInternal to serve it over http.

I already use the http server, what I mean in my question is that may it cannot served over http directly from external storage, but should be copied to DirInternal.

For final end users, this should be transparent, without have to put anything.
Suppose you create a 3D game, or just an app that use 3D, the final user don't have to place some files to make it working.

My question was only referred to the developer side, but I even have to consider the final end user experience,
probably for this the best option remains to copy the zip from assets, so the end user don't have to do nothing, just install the app and run.

There is another option I have to explore better. When the developer create one app, then create a second app, if the package name remain the same (eg. b4a.example), probably the second app will use the previous DirInternal app folder (and android install the app as update of first app), if here we already placed the three.js distribution, it already exist and can be reused for the new app, simply the app will be overwrited.
But I'm not sure what really happen ... and even if this happen you will end up to have just the last app installed, but if this happen, this will avoid to manually copy the zip file to every project asset folder, and when first time run the second app, the library see that three.js already exist and there's no need to copy and unzip from assets.

What would be very useful in B4A would be to have (as happens on B4J with DirData) a common folder that points not to Android, but to a specific folder of the development system (desktop PC) so that it is visible to all B4A projects, where the code then picks up the files to copy into DirInternal if they does not already exist.

What I mean is File.DirData() on B4A, that point to the same folder than File.DirData() on B4J, so in my case to:
C:\Users\MyUserName\AppData\Roaming\B4XWebGL so referred to the develop pc side, not android, and the IDE just wil use that folder the same way it refer to files placed in File Tab, this just only to avoid that the user have to copy these files manually in any project asset folder. So just a reference to a common folder on develop machine, managed to be as Asset folder.

This is not too much different than the IDE Additional Library folder, or Shared classes, where the IDE search additional libraries in the position specified in settings, it should be similar, but by code using File.DirData().
 
Last edited:
Upvote 0
Top