Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update to new V8Snapshot generator #13911

Merged
merged 2 commits into from
Sep 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 6 additions & 14 deletions android/titanium/libv8-services.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,33 +171,26 @@ async function createSnapshot() {
// Requests our server to create snapshot of rolled-up "ti.main" in a C++ header file.
let wasSuccessful = false;
try {
// Post rolled-up "ti.main" script to server and obtain a snapshot ID as a response.
// We will send an HTTP request for the snapshot code later.
// Post rolled-up "ti.main" script to server and obtain the V8Snapshot.h as a response.
console.log('Attempting to request snapshot...');
const snapshotUrl = 'http://v8-snapshot.appcelerator.com'; // TODO: Migrate to Github Artifacts once ready
const snapshotUrl = 'https://v8-snapshot.titaniumsdk.com/gen';
const packageJsonData = await loadPackageJson();
const requestOptions = {
body: {
v8: packageJsonData.v8.version,
script: rollupFileContent
},
json: true
json: true,
resolveWithFullResponse: true,
timeout: 60 * 1000 * 5
};
const snapshotId = await request.post(snapshotUrl, requestOptions);

// Request generated snapshot from server using `snapshotId` obtained from server above.
const MAX_ATTEMPTS = 20; // Time-out after two minutes.
let attempts;
for (attempts = 1; attempts <= MAX_ATTEMPTS; attempts++) {
const response = await request.get(`${snapshotUrl}/snapshot/${snapshotId}`, {
simple: false,
resolveWithFullResponse: true
});
const response = await request.post(snapshotUrl, requestOptions);

if (response.statusCode === 200) {

// Server has finished creating a C++ header file containing all V8 snapshots.
// Write it to file and flag that we're done.
console.log('Writing snapshot...');
await fs.writeFile(v8SnapshotHeaderFilePath, response.body);
wasSuccessful = true;
Expand All @@ -208,7 +201,6 @@ async function createSnapshot() {
console.log('Waiting for snapshot generation...');
await new Promise(resolve => setTimeout(resolve, 6000));
} else {

// Give up if received an unexpected response.
console.error('Could not generate snapshot, skipping...');
break;
Expand Down