App exit (crash) when load multiples big images


#1

In my app I have fresco LIB but when images from camera are too bigs and load more than 3 images the app crashes/exits with no error, just closes the app

any idea??

nativescript │ 2.5.4
tns-core-modules │ 2.5.2
tns-android │ 2.5.0
nativescript-fresco │ ^1.0.16 │


#2

I faced similar issues while reading/writing large files. Did you try adding android:largeHeap="true" to your application tag in manifest file.


#3

didn’t fix it =( the app get slow… and eventually crash/exit


#4

@jcasanova
Did you try using nativescript-fresco?


#5

Hi @multishiv19 , yeah i’m using fresco… thats why i’m asking… because it should handle that kind of things…


#6

what is the average size of images you try to load?
I would recommend to keep it as small as possible.
Load larger images only inside things like nativescript-imageswiper


#7

the images are from the camera, so… are 1MB to 3MB but I’m working in downsample the image, but I cant use imageswiper because the app has a layout predefined.


#8

@jcasanova
Here’s how you downsample it
you take the args.image you get from camera, then
say, source = args.image,
now you do,

    const fs = require("file-system");
    const folder = fs.knownFolders.documents().path;
    const fileName = "imagename.png";
    const path = fs.path.join(folder, fileName);
    const saved = source.saveToFile(path, "png", 100);

The variable saved, contains the downsampled file. you can upload that, or set as a source of image.

Cheers! Happy NativeScripting


#9

hi, what would be “source” ?


#10

source is an instance of ImageSource