@@ -454,6 +454,7 @@ Isolate* Runtime::PrepareV8Runtime(const string& filesPath, const string& native
454
454
455
455
void * snapshotPtr = nullptr ;
456
456
string snapshotPath;
457
+ bool snapshotPathExists = false ;
457
458
458
459
// If device isn't running on Sdk 17
459
460
if (m_androidVersion != 17 ) {
@@ -488,20 +489,28 @@ Isolate* Runtime::PrepareV8Runtime(const string& filesPath, const string& native
488
489
// we have a precompiled snapshot blob provided - try to load it directly
489
490
if (!Constants::V8_HEAP_SNAPSHOT_BLOB.empty ()) {
490
491
snapshotPath = Constants::V8_HEAP_SNAPSHOT_BLOB;
492
+ snapshotPathExists = File::Exists (snapshotPath);
491
493
saveSnapshot = false ;
492
494
} else {
493
- snapshotPath = filesPath + " /internal/snapshot.blob" ;
495
+ std::string oldSnapshotBlobPath = filesPath + " /internal/snapshot.blob" ;
496
+ std::string snapshotBlobPath = filesPath + " /internal/TNSSnapshot.blob" ;
497
+
498
+ bool oldSnapshotExists = File::Exists (oldSnapshotBlobPath);
499
+ bool snapshotExists = File::Exists (snapshotBlobPath);
500
+
501
+ snapshotPathExists = oldSnapshotExists || snapshotExists;
502
+ snapshotPath = oldSnapshotExists ? oldSnapshotBlobPath : snapshotBlobPath;
494
503
}
495
504
496
- if (File::Exists (snapshotPath) ) {
505
+ if (snapshotPathExists ) {
497
506
m_heapSnapshotBlob = new MemoryMappedFile (MemoryMappedFile::Open (snapshotPath.c_str ()));
498
507
m_startupData->data = static_cast <const char *>(m_heapSnapshotBlob->memory );
499
508
m_startupData->raw_size = m_heapSnapshotBlob->size ;
500
509
V8::SetSnapshotDataBlob (m_startupData);
501
510
isCustomSnapshotFound = true ;
502
511
DEBUG_WRITE_FORCE (" Snapshot read %s (%zuB)." , snapshotPath.c_str (), m_heapSnapshotBlob->size );
503
512
} else if (!saveSnapshot) {
504
- DEBUG_WRITE_FORCE (" No snapshot file found at %s " , snapshotPath. c_str () );
513
+ throw NativeScriptException (" No snapshot file found at: " + snapshotPath);
505
514
} else {
506
515
// This should be executed before V8::Initialize, which calls it with false.
507
516
NativeScriptExtension::CpuFeaturesProbe (true );
0 commit comments