NativeScript / android

NativeScript for Android using v8
https://docs.nativescript.org/guide/android-marshalling
Apache License 2.0
519 stars 135 forks source link

Remove remainder of support for external startup data #1758

Closed ptomato closed 1 year ago

ptomato commented 1 year ago

Description

As per https://github.com/NativeScript/NativeScript/issues/8926, external startup data is no longer supported. We can gain a small amount of size savings by building V8 with support for external startup data switched off.

Without the machinery to load an external snapshot from a file, nothing is using MemoryMappedFile any longer, so we can remove it. File::Exists has one remaining usage, but that usage is redundant, so we can remove it as well.

As you can see in this PR, the V8 libraries get slightly larger (30–40 kb depending on architecture) because they now include the snapshot internally. But the total size of an APK shrinks, because we don't need to link the external startup data into the runtime. I tested with a hello world app, and got -564 kb for debug, -23 kb for release.

We also don't need to separately commit snapshot_blob.h to this repo anymore, which makes the process for modifying V8 slightly easier.

The V8 artifacts added in this PR were built from my fork of v8-buildscripts, with commits from https://github.com/NativeScript/v8-buildscripts/pull/2 ported to all the Android branches. Unfortunately I had to delete and recreate my fork in order to open the PR (I guess because I forked it when the repo was private?) so the jobs that created those artifacts are gone. In order to establish provenance for the artifacts, what I'd recommend is to review and merge https://github.com/NativeScript/v8-buildscripts/pull/2 first and port it to the other Android branches, then we can rebuild all 4 of them and I'll update this PR with the resulting artifacts from those jobs.

Related Pull Requests

Does your pull request have unit tests?

No tests; all functionality should be unchanged, except that the heapSnapshotScript and snapshot.blob config options should now be ignored completely.

ptomato commented 1 year ago

I've updated the artifacts with information on how they were built using NativeScript/v8-buildscripts. This is ready for review/merge now.