Start a new topic

Remote 3d models are never erased from the app

Hi there,


So I get my 3d models and target collection files from my server. I then dynamically create the 3d models. Some of the 3d model files are as large as 50 MB and we are working to reduce that to 5-10 MB the most. But regardless of that, every time we startup the app, seems like the 3d files are locally downloaded and never deleted. So every time we use the app, the app size increases by 50-100 MB. Is there a way to release the storage somehow?


The part of the code that builds the 3d models:

 

_.forEach(this.nearbyEvent.targets, function(target) {
        console.log("target", target);
        // Only setup Image Rec if there are indeed some overlays available
        if (target.eventTargetOverlays && target.eventTargetOverlays.length > 0) {
          // First create the overlays for the target
          var overlayDrawables = [];
          _.forEach(target.eventTargetOverlays, function(overlay) {
            overlayDrawables.push(new AR.Model(overlay.overlayUrl, {
              onLoaded: World.loadingStepDone,
              translate: overlay.translate,
              scale: overlay.scale,
              rotate: overlay.rotate
            }));
          });
          // Then create the image trackable for the target
          var trackable = new AR.ImageTrackable(World.tracker, target.title, {
            drawables: {
              cam: overlayDrawables
            }
          });
          World.allTrackables.push(trackable);
        }
      });



Thanks in advance!


Hello Farshid,

Please ensure to properly destroy objects you do not need anymore by calling objects.destroy() function. You can find more information here.

Thanks
Eva

 

Thanks Eva,


I have tried your approach but unfortunately it didn't work. I also decided to load the models only `onImageRecognized` method. and I destroy them `onImageLost`. Here's my approach:


 

_.forEach(this.nearbyEvent.targets, function(target) {
        // Only setup Image Rec if there are indeed some overlays available
        if (target.eventTargetOverlays && target.eventTargetOverlays.length > 0) {
          World.overlays[target.title] = target.eventTargetOverlays;
          World.allTimeOuts[target.title] = undefined;
          // Create the image trackable for the target
          var trackable = new AR.ImageTrackable(World.tracker, target.title, {
            onImageRecognized: function(targetName) {
              // Only add drawable if they are not yet loaded
              if (trackable.drawables.cam.length === 0) {
                _.forEach(World.overlays[targetName], function (overlay) {
                    trackable.drawables.addCamDrawable(new AR.Model(overlay.overlayUrl, {
                      onLoaded: World.loadingStepDone,
                      translate: overlay.translate,
                      scale: overlay.scale,
                      rotate: overlay.rotate
                    }));
                });
                // Clear the timeout if timeout has not yet run
                if (World.allTimeOuts[targetName]) {
                  clearTimeout(World.allTimeOuts[targetName]);
                }
              }
            },
            onImageLost: function(targetName) {
              // Destroy the models/image if the user doesn't return to the target in 10 seconds
              if (trackable.drawables.cam.length > 0)
              World.allTimeOuts[targetName] = setTimeout(function(){
                _.forEach(trackable.drawables.cam, function(drawable) {
                  if (drawable) {
                    trackable.drawables.removeCamDrawable(drawable);
                    drawable.destroy();
                  }
                });
                World.allTimeOuts[targetName] = undefined;
              }, 3000);
            }
          });
          World.allTrackables.push(trackable);
        }
      });

 

I also have notice that the destroy function works fine and the model is not downloaded anymore once you move in and out of the target, but once you restart the app, the model is re-downloaded and adds to the app size in iPhone settings. Not sure how can you fully remove the model file from the app???

Any solution to this? Seems like I'm doing all the necessary steps as suggested here and other posts. Any help would be greatly appreciated.



Good morning Farshid,



my apologies for the delay, I've been on vacation recently. 


I did finally manage to have a look at this. The issue lies with our loading procedure of 3D models; we failed to clean up some of the persistently created data resulting from it. I implemented a fix for it which will ship with the next release of the SDK. I'm afraid there is nothing you can do on your side for now.



- Daniel


Thanks Daniel. Does 7.1.0 has this fix?

Good morning Farshid,



version 7.1.0 does not have this fix included, it will be release with 7.2.0 for which there is no date yet, but it might be a while since we just released 7.1.0. If you should require a fix before that, I could provide a custom build for you to use in the meantime.



- Daniel

Thanks Daniel for your quick response.  It really depends on the possible release date of 7.2 (I doubt it'd be any time soon :( ) A custom build would be greatly appreciate it since we'll be running this in a lot of events and there could be a lot of targets and models in each event. The problem is it keeps adding up to the storage and that's a big flaw for us. 


Best,

Farshid

Hi Farshid,



Which SDK package(s) are you using, exactly? JavaScript iOS? JavaScript Android? Cordova? Titanium? Xamarin?



- Daniel


JavaScript iOS

Hello Farshid, 



here you go. Please note that this is a nightly build that has some entirely untested code in it. Therefore I cannot make any guarantees regarding its stability. Having said that, since the it's largely based on the state of the recent release, I would expect it to be very stable still.


Please let me know whether this package fixes the problems you are currently having.



- Daniel


Thanks a lot Daniel! I'm in the process of converting my app to swift 4. Once that done, I'll be able to test Wikitude. 


Again, thanks and I will keep you posted

Login or Signup to post a comment