@@ -454,6 +454,7 @@ Isolate* Runtime::PrepareV8Runtime(const string& filesPath, const string& native
454454
455455 void * snapshotPtr = nullptr ;
456456 string snapshotPath;
457+ bool snapshotPathExists = false ;
457458
458459 // If device isn't running on Sdk 17
459460 if (m_androidVersion != 17 ) {
@@ -488,20 +489,28 @@ Isolate* Runtime::PrepareV8Runtime(const string& filesPath, const string& native
488489 // we have a precompiled snapshot blob provided - try to load it directly
489490 if (!Constants::V8_HEAP_SNAPSHOT_BLOB.empty ()) {
490491 snapshotPath = Constants::V8_HEAP_SNAPSHOT_BLOB;
492+ snapshotPathExists = File::Exists (snapshotPath);
491493 saveSnapshot = false ;
492494 } 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;
494503 }
495504
496- if (File::Exists (snapshotPath) ) {
505+ if (snapshotPathExists ) {
497506 m_heapSnapshotBlob = new MemoryMappedFile (MemoryMappedFile::Open (snapshotPath.c_str ()));
498507 m_startupData->data = static_cast <const char *>(m_heapSnapshotBlob->memory );
499508 m_startupData->raw_size = m_heapSnapshotBlob->size ;
500509 V8::SetSnapshotDataBlob (m_startupData);
501510 isCustomSnapshotFound = true ;
502511 DEBUG_WRITE_FORCE (" Snapshot read %s (%zuB)." , snapshotPath.c_str (), m_heapSnapshotBlob->size );
503512 } 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);
505514 } else {
506515 // This should be executed before V8::Initialize, which calls it with false.
507516 NativeScriptExtension::CpuFeaturesProbe (true );
0 commit comments