Skip to content

Commit

Permalink
Upgrade to WebKitGTK 2.36.3 (#169)
Browse files Browse the repository at this point in the history
# Why

upgrade to latest WebKitGTK 2.36.3 (svn r294992). mostly from community requests and hopefully to fix the crashes on samsung android 12 devices.

# How

- upgrade NDK to 23.2.8568313. we need newer versions because the newer webkit needs std::filesystem that doesn't support on NDK r21. also, because the NDK r23 libc++_shared.so has std::filesystem symbols that older version doesn't have. to prevent developers use pickFirst to pick wrong libc++_shared.so, i turned to use link static c++ runtime instead.
- **[BREAKING CHANGE]** remove non Intl variant, because newer JSC doesn't have a build flag to turn it off.
- **[BREAKING CHANGE]** Bump minimum supported Android SDK to 21
- remove outdated patches for older jsc or ndk
- remove some platform specific cflags, let ndk to do it.

size changes:

|      -      | r250230 Intl | r294992 Intl |
| :---------: | :----------: | :----------: |
| armeabi-v7a |    14 MB     |    17 MB     |
|  arm64-v8a  |    18 MB     |    19 MB     |
|     x86     |    17 MB     |    20 MB     |
|   x86_64    |    19 MB     |    21 MB     |
  
# Test Plan

- ci passed.
- launch test on arm64 devices
  • Loading branch information
Kudo authored Jul 12, 2022
1 parent ef2df99 commit 6b1ec06
Show file tree
Hide file tree
Showing 25 changed files with 140 additions and 505 deletions.
30 changes: 19 additions & 11 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,42 @@
name: Build jsc-android and test

on: [push, pull_request]
on:
push:
branches: [main]
pull_request:

jobs:
build:
runs-on: ubuntu-latest
container: reactnativecommunity/react-native-android:2019-9-4
container: reactnativecommunity/react-native-android:5.4

steps:
- uses: actions/checkout@v1

- name: Install packages
run: |
apt-get update
apt-get install coreutils realpath curl git subversion python3.5 python3.5-dev ruby gperf -y
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.5 1
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.1/install.sh | bash
apt-get install coreutils curl git subversion wget python3 ruby gperf -y
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
echo 'export NVM_DIR="$HOME/.nvm"' >> "${HOME}/.bashrc"
echo '[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm' >> "${HOME}/.bashrc"
source "${HOME}/.bashrc"
nvm install 10
nvm use 10
nvm alias default 10
nvm install 16
nvm use 16
nvm alias default 16
shell: bash

- name: Install Android packages
run: |
sdkmanager \
"cmake;3.10.2.4988404"
"cmake;3.10.2.4988404" \
"cmake;3.18.1" \
"ndk;23.2.8568313"
# move out builtin icu headers from ndk and prevent icu build errors
mv "${ANDROID_HOME}/ndk/23.2.8568313/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/unicode" "${ANDROID_HOME}/ndk/23.2.8568313/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/unicode2"
echo "ANDROID_NDK=$ANDROID_HOME/ndk/23.2.8568313" >> $GITHUB_ENV
shell: bash

- name: Build
run: |
yarn clean
Expand Down Expand Up @@ -64,7 +72,7 @@ jobs:
- name: Run test
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 16
arch: x86
api-level: 21
arch: x86_64
disable-animations: false
script: mv archive/dist . && cd test && yarn && cd android && ./gradlew assembleRelease assembleAndroidTest connectedAndroidTest
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package-lock.json
/build
/dist
/dist.unstripped

# Created by https://www.gitignore.io/api/node,android,reactnative,intellij+all,androidstudio,visualstudiocode

Expand Down
45 changes: 0 additions & 45 deletions lib/cppruntime/build.gradle

This file was deleted.

2 changes: 0 additions & 2 deletions lib/cppruntime/src/main/AndroidManifest.xml

This file was deleted.

1 change: 0 additions & 1 deletion lib/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
rootProject.name = 'JavaScriptCore Lib'

include ':android-jsc'
include ':cppruntime'
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jsc-android",
"version": "250230.2.1",
"version": "294992.0.0",
"description": "Pre-build version of JavaScriptCore to be used by React Native apps",
"repository": {
"type": "git",
Expand All @@ -26,8 +26,8 @@
"start": "./scripts/start.sh"
},
"config": {
"webkitGTK": "2.26.1",
"chromiumICUCommit": "64e5d7d43a1ff205e3787ab6150bbc1a1837332b"
"webkitGTK": "2.36.3",
"chromiumICUCommit": "85814e1af52482199a13d284545623ffbc9eef83"
},
"devDependencies": {
"commander": "^4.0.1",
Expand Down
13 changes: 13 additions & 0 deletions patches/jsc.patch
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,16 @@

# Force staging of shared scripts, even if they aren't directly used to build JavaScriptCore.

--- target-org/webkit/Source/cmake/OptionsJSCOnly.cmake 2022-07-09 15:31:32.000000000 +0800
+++ target/webkit/Source/cmake/OptionsJSCOnly.cmake 2022-07-10 12:40:43.000000000 +0800
@@ -58,8 +58,8 @@
# https://bugs.webkit.org/show_bug.cgi?id=172862
if (NOT ENABLE_STATIC_JSC AND NOT WIN32)
set(JavaScriptCore_LIBRARY_TYPE SHARED)
- set(bmalloc_LIBRARY_TYPE OBJECT)
- set(WTF_LIBRARY_TYPE OBJECT)
+ set(bmalloc_LIBRARY_TYPE STATIC)
+ set(WTF_LIBRARY_TYPE STATIC)
endif ()

if (WIN32)
68 changes: 24 additions & 44 deletions patches/jsc_features.patch
Original file line number Diff line number Diff line change
@@ -1,54 +1,34 @@
diff -aur target-org/webkit/CMakeLists.txt target/webkit/CMakeLists.txt
--- target-org/webkit/CMakeLists.txt 2017-12-22 19:18:43.000000000 +0200
+++ target/webkit/CMakeLists.txt 2018-06-14 15:41:59.000000000 +0300
@@ -177,13 +177,13 @@
--- target-org/webkit/CMakeLists.txt 2021-03-06 03:12:45.000000000 +0800
+++ target/webkit/CMakeLists.txt 2022-07-09 18:13:01.000000000 +0800
@@ -38,9 +38,9 @@
add_subdirectory(Tools)
endif ()

-if ("${PORT}" STREQUAL "GTK" OR "${PORT}" STREQUAL "WPE")
- if (DEVELOPER_MODE)
- add_subdirectory(PerformanceTests)
- endif ()
-else ()

-if (DEVELOPER_MODE)
- add_subdirectory(PerformanceTests)
-endif ()
+#if ("${PORT}" STREQUAL "GTK" OR "${PORT}" STREQUAL "WPE")
+# if (DEVELOPER_MODE)
+# add_subdirectory(PerformanceTests)
+# endif ()
+#else ()
+# add_subdirectory(PerformanceTests)
+#endif ()

+# if (DEVELOPER_MODE)
+# add_subdirectory(PerformanceTests)
+# endif ()

# -----------------------------------------------------------------------------
# Print the features list last, for maximum visibility.
diff -aur target-org/webkit/Source/cmake/OptionsJSCOnly.cmake target/webkit/Source/cmake/OptionsJSCOnly.cmake
--- target-org/webkit/Source/cmake/OptionsJSCOnly.cmake 2019-03-26 11:25:17.000000000 +0800
+++ target/webkit/Source/cmake/OptionsJSCOnly.cmake 2019-03-26 11:28:29.000000000 +0800
@@ -35,12 +35,7 @@
set(ENABLE_WEBCORE OFF)
set(ENABLE_WEBKIT_LEGACY OFF)
set(ENABLE_WEBKIT OFF)
-
-if (WIN32)
- set(ENABLE_API_TESTS OFF)
-else ()
--- target-org/webkit/Source/cmake/OptionsJSCOnly.cmake 2022-07-09 15:31:32.000000000 +0800
+++ target/webkit/Source/cmake/OptionsJSCOnly.cmake 2022-07-09 15:29:24.000000000 +0800
@@ -47,7 +47,7 @@
if (WIN32)
set(ENABLE_API_TESTS OFF)
else ()
- set(ENABLE_API_TESTS ON)
-endif ()
+set(ENABLE_API_TESTS OFF)

+ set(ENABLE_API_TESTS OFF)
endif ()
if (WTF_CPU_ARM OR WTF_CPU_MIPS)
SET_AND_EXPOSE_TO_BUILD(USE_CAPSTONE TRUE)
diff -aur target-org/webkit/Source/JavaScriptCore/CMakeLists.txt target/webkit/Source/JavaScriptCore/CMakeLists.txt
--- target-org/webkit/Source/JavaScriptCore/CMakeLists.txt 2017-05-02 21:13:03.000000000 +0200
+++ target/webkit/Source/JavaScriptCore/CMakeLists.txt 2017-07-11 11:34:55.962374878 +0200
@@ -1291,7 +1291,7 @@
)
target_include_directories(LLIntOffsetsExtractor SYSTEM PRIVATE ${JavaScriptCore_SYSTEM_INCLUDE_DIRECTORIES})

--- target-org/webkit/Source/JavaScriptCore/CMakeLists.txt 2022-07-09 15:31:21.000000000 +0800
+++ target/webkit/Source/JavaScriptCore/CMakeLists.txt 2022-07-09 15:31:50.000000000 +0800
@@ -1564,4 +1565,4 @@
VERBATIM)
endif ()

-add_subdirectory(shell)
+# add_subdirectory(shell)

WEBKIT_COMPUTE_SOURCES(JavaScriptCore)
WEBKIT_WRAP_SOURCELIST(${JavaScriptCore_SOURCES})

20 changes: 0 additions & 20 deletions patches/jsc_fix_build_error_getline.patch

This file was deleted.

21 changes: 0 additions & 21 deletions patches/jsc_fix_build_error_log2.patch

This file was deleted.

40 changes: 0 additions & 40 deletions patches/jsc_fix_build_error_memalign.patch

This file was deleted.

29 changes: 0 additions & 29 deletions patches/jsc_fix_build_error_mulodi4.patch

This file was deleted.

15 changes: 0 additions & 15 deletions patches/jsc_fix_build_error_statvfs.patch

This file was deleted.

Loading

1 comment on commit 6b1ec06

@yinyinnie
Copy link

Choose a reason for hiding this comment

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

"link static c++ runtime" may produce some issues. as Android official doc said: "in practice crashes are very common" https://developer.android.com/ndk/guides/cpp-support#sr

Please sign in to comment.