App size (documents&data) increases every time when using the app enormously

Hey I wanted to create a little project, where I show a gif image and when a button is pressed/swiped the next gif image will be loaded and shown.

So I found a site (http://www.funcage.com/gif/?) which shows everytime you refresh the homepage a new gif. My idea was to parse the link of the gif and show it into an webview.

Everything is working but everytime a couple of new gifs are shown, the app size increases about a couple MB’s. I can see this under settings, where it shows the size of Documents and Data, which for my app is increasing. And even when I terminate/close the app, the size keeps the same.

I exported it to an iPhone 5C running the latest iOS version.

Here is the javascript code:

var Observable = require("FuseJS/Observable");

var link = Observable("http://www.google.com");
var split;
var line;

 function nextGIF(args){
      baseSite.goto("http://www.funcage.com/gif/?");
 }


  module.exports = {


onPageLoaded : function(res) {
    split = "";
    split = JSON.parse(res.json).data.split("\n");

    line = "nichts :(";
    for (i = 0; i < split.length; i++){
    line = split[i];
    if (line.includes("/gif/m/funnypicture.php?image=../photos/")){
        break;
    }
}

var start = line.indexOf("/photos/");
var end = line.indexOf("\"", start);
var finalLink = "http://www.funcage.com/gif&quot; + line.substring(start, end);
gifSite.goto(finalLink);
router.goto("next");
},
nextGIF: nextGIF
};

And then in the ux code here is the part, which belongs to the webview

...
      <NativeViewHost>
        <WebView CachingMode="Never" Opacity="0" ux:Name="baseSite" Layer="Background" Url="http://www.funcage.com/gif/?"&gt;
            <PageLoaded>
                <EvaluateJS Handler="{onPageLoaded}">
                    var result = {
                        url : document.location.href,
                        data : document.body.innerHTML
                    };
                    return result;
                </EvaluateJS>
            </PageLoaded>
        </WebView>
    </NativeViewHost>

   <NativeViewHost>
       <WebView CachingMode="Never" ClipToBounds="true" ux:Name="gifSite" Url="http://www.funcage.com/gif/photos/birds-are-assholes.gif&quot; Dock="Fill">
        </WebView>
    </NativeViewHost>
    ...

What is going on here? Is he saving all the pages on my iPhone?

Fuse version 0.23.0 (build 7041)

I may be wrong, but I believe that site has a memory leak, or its not garbage collecting a certain amount. But that’s how it works, the more you load the more memory is gonna take. I believe the best way would be to just have a server which requests the site, you grab the image url, and then send it back to your app. Yet I’m wondering are you just trying to make the site a mobile app, by wrapping it in a WebView, if so there are better tools for that will wrap your site in a webview native app (idk what’s it called). Take a look at Electron.

I’ve looked in detail (with iExplorer) inside the Application what files are taking up the space and it’s:

Library/Caches/WebKit/NetworkCache/Version 4/Blobs/{here are the files}

All the files have names like this: 514D0C0769D9867E1E18023C246DDA30B26E089B But I could open them with Google Chrome and they are exactly the gifs that I wachted.

So how can I solve this problem? I don’t want to keep caches. At least the cache should be cleared when the app is closed.

I have no idea how to do this, hopefully the Fuse team does

Hi!

We are using the native WebView in iOS and Android, so the memory used is the native browser doing caching. Are you seeing alarmingly high memory usage? WebView will clear its cache if it gets a low memory warning.

It is possible to free the memory held by the native WebView, but we have to expose that in UX, something that isn’t currently implemented.

Hey Vegard :slight_smile:

For me the cache was about 30MB, and I only have 8GB total space on my iPhone 5C :smiley: So it’s too much :confused:

I really would like the cache feature exposed to UX :slight_smile: