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(android): update V8 to 7.3.492.26 #10817

Merged
merged 3 commits into from Apr 12, 2019

Conversation

garymathews
Copy link
Contributor

  • Update V8 runtime to 7.3.492.26
    • Use snapshot blobs to improve startup time by 50%

TIMOB-26957
TIMOB-26909

@build
Copy link
Contributor

build commented Apr 1, 2019

Messages
📖

💾 Here's the generated SDK zipfile.

📖

✅ All tests are passing
Nice one! All 3647 tests are passing.

Generated by 🚫 dangerJS against 04186e5

@sgtcoolguy
Copy link
Contributor

sgtcoolguy commented Apr 1, 2019

I assume this breaks native modules (i.e. we need to hold for 9.0 and bump the module api version)?

Or did you manage to retain our patches to v8 that retained the removed APIs?

Given that Android crashes on startup in our test suite, I'll bet that this means we need to re-build our modules, bump the api version and target this against "next" branch.

@garymathews
Copy link
Contributor Author

@sgtcoolguy Currently working on that, should be able to get backwards compatibility.

@garymathews
Copy link
Contributor Author

garymathews commented Apr 7, 2019

@sgtcoolguy Fixed native module compatibility, looks like Google Play Services needs updating on the emulator for the ti.map tests to pass.

GooglePlayServicesUtil: Google Play services out of date.  Requires 13400000 but found 13280022

@sgtcoolguy
Copy link
Contributor

@garymathews this still crashes the android emulator - presumably backwards native module compat is still broken?

@sgtcoolguy
Copy link
Contributor

Gary and I spoke about this on a back channel chat. Before merging I'd like to see the generation of the snapshot header file automated.

Long-term I think that means mksnapshot binaries become packaged with the V8 libraries in the zip file on the v8_titanium side; and on this side, our build scripts to use the mksnapshot binaries to generate the header when the v8 library is updated and then hooked into our builds.

That does present an issue if we're not generating a windows compatible mksnapshot binary and devs try to build the SDK on Windows (like Yordan does).

@garymathews garymathews force-pushed the TIMOB-26909 branch 3 times, most recently from a6d267c to 7886042 Compare April 9, 2019 23:44
@garymathews
Copy link
Contributor Author

Made the necessary changes to V8 so that:

  • Modules compiled with 7.X.X - 8.0.X are compatible with 8.1.0
  • Modules compiled with 8.1.0 are compatible with 7.X.X+

Once 7.3-lkgr has built, we can re-build this PR.

Copy link
Contributor

@sgtcoolguy sgtcoolguy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR looks fine to me, passes all the tests and looks to be a nice performance boost - awesome work Gary!

The comments from me are just stylistic JS nitpicks

};
return ant.build(ANDROID_BUILD_XML, [ 'full.build' ], properties);
// Clean build and download V8
await this.clean().catch(error => console.error(error));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

really don't need the catch chained here, it'll bubble up the Error if there is one. adding a catch will actually just log it and move on.


// Generate snapshots
const snapshot = require('./snapshot');
await snapshot.build().catch(error => console.error(error));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, no need for a catch really.

];

// Set correct permissions for 'mksnapshot'
fs.chmodSync(MKSNAPSHOT_PATH, 0o755);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the method is async, so you could do await fs.chmod(MKSNAPSHOT_PATH, 0o755);

return new Promise((resolve, reject) => {

// Snapshot already exists, skip...
if (fs.existsSync(BLOB_PATH)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could be moved out of the Promise and use await fs.exists(BLOB_PATH)

const blobs = {};

// Load snapshots for each architecture
for (const target of TARGETS) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again this method is async, so you can use the async fs methods.

Additionally, you could use probably refactor this very slightly to read in all the blobs in parallel by using Promise.all(TARGETS.map());

}
}

return new Promise(async (resolve, reject) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused by the async here...

Generally I try to make use of util.promisify to handle older callback style APIs so I can avoid the hand-written Promise instances. so in this case you could do:

const promisify = require('util').promisify; // at the top of the file
const renderFile = promisify(require('ejs').renderFile);
// ...
const output = await renderFile(path.join(__dirname, 'V8Snapshots.h.ejs'), blobs, {});
return fs.writeFile(path.join(ANDROID_DIR, 'runtime', 'v8', 'src', 'native', 'V8Snapshots.h'), output);

* @returns {Promise<void>}
*/
async function build() {
return new Promise(async (resolve, reject) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again, if the method is async, you shouldn't need to hand write a Promise instance:

// Only macOS is supports creating snapshots
if (os.platform() !== 'darwin') {
    return;
}

// generate snapshots in parallel
await Promise.all(TARGETS.map(t => generateBlob(t)));
return generateHeader();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants