Just starting out? Need help? Post your questions and find answers here.
Posts: 33
Joined: Sun Mar 17, 2019 5:51 pm

Replacing SB function FreeImage() ? Or other image use?

by hoerbie Sun Nov 10, 2019 5:49 pm


I think a question for the JS/SB pros here:

I actually have a lot of problems with a SB app on iOS. The app does a lot of LoadImage (sometimes only ~10 but up to ~200 images) at startup, because it needs to work without network connection after the start for some time.

But the app stops all image functions after some usage (copying and resizing for the ImageGadget, showing one image a time), so showing another image simply shows a blank gadget, additional LoadImage don't call callbacks etc.

All images are loaded and used as "canvas"-objects internally in SB, and there seems to be a relatively low memory limit on iOS for canvasses, also there seems to be a memory leak in iOS or the canvasses are simply not deleted when using SBs FreeImage(), see for example https://stackoverflow.com/questions/52532614/total-canvas-memory-use-exceeds-the-maximum-limit-safari-12. Using Chromes performance analysis there seems to be no leak in browser, and I couldn't find the same problem in Android.

The original function is:
Code: Select all
function spider_FreeImage(a)
   var b;
   else if(b=spider.image.objects.Get(a))

So my idea was (sorry, I'm not a JS pro) a simple version to only delete one image every call (the above "else if" tree):
Code: Select all
Procedure FreeImageEx(img.i)
   ! var b;
   ! b = spider.image.objects.Get(v_img);
   ! b.image.height = 0;
   ! b.image.width = 0;
   ! spider.image.div.removeChild(b.image);
   ! spider.image.objects.Remove(v_img);

Is this the right way?

With the official SBs FreeImage my app stops doing any "image" functions really fast, with my new FreeImageEx the app is usable a lot longer, but still stops some time later all "image" functions....

Are there any alternatives? I don't need to change the images, so "canvas" isn't really needed.

I only need to preload the images and show one image at the right place in right size, so some simple JS for preloading and some simple output of
Code: Select all
<img src="<imageid_or_url>" width="<usablex>" height="<usabley>">

in the right div would be enough.

Greetings & Thanks,
Return to Coding Questions

Who is online

Users browsing this forum: No registered users and 6 guests