Yes, sorry, I should also have mentioned that I don't know how it crashes as the crash is so spectacular that Xcode reports nothing.
I set break points to make sure it was the execution that it crashed in because there is no stack trace reported.
In the function below the crash occurs at line 12 so I know the VM loads the JS but then dies on execution.
Running on my iPhone X I selected the debug navigator top left of Xcode and watched memory usage shoot up to 1.74G before it ***** out. That was loading the 357Mb JS file.
The device is cleared from Xcode and is no longer selectable until I recompile and reload. (Xcode 11.5, iOS12 for iPad Mini and iOS13.5 on all other devices)
We've run additional tests using models of varying sizes on all the platforms that we have so we can figure out the limits.
Devices with 2Gb of memory can run JS files up to 150Mb.
It maybe higher but that was as high as we went other than the 357Mb file that only my iPad Pro will run.
We plan to split the processing over multiple files passing the result from each execution between them for now.
Code Block - (NSDictionary *) processBatchFile: (NSString *) filePath { |
NSError *error; |
NSString *jsonData = [NSString stringWithContentsOfFile:filePath |
encoding:NSUTF8StringEncoding |
error:&error]; |
if (error) { |
NSLog(@"processBatchFile: batch load failed. %@",error); |
return Nil; |
} |
NSLog(@"processBatchFile: %@",[filePath lastPathComponent]); |
JSValue *jsProcessor = self.jsContext[@"processBatch"]; |
JSValue *result = [jsProcessor callWithArguments:@[jsonData, self.configs]]; |
NSLog(@"processBatchFile: result = %@",[result toDictionary]); |
return [result toDictionary]; |
} |