Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into feature/prebuild_v8
Browse files Browse the repository at this point in the history
  • Loading branch information
zealotchen0 committed May 20, 2024
2 parents 3581c8c + 60fd4eb commit b99a30c
Show file tree
Hide file tree
Showing 80 changed files with 1,670 additions and 501 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/ios_build_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ jobs:
uses: actions/checkout@v3
with:
lfs: true
- name: Xcodegen
uses: xavierLowmiller/xcodegen-action@1.1.2
with:
spec: framework/examples/ios-demo/project.yml
version: '2.32.0'
- name: Demo
working-directory: framework/examples/ios-demo
run: |
Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/project_artifact_compare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,10 @@ jobs:
with:
ref: ${{ matrix.ref }}
lfs: true
- name: Xcodegen
uses: xavierLowmiller/xcodegen-action@1.1.2
with:
spec: framework/examples/ios-demo/project.yml
version: '2.32.0'
- name: Build
if: ${{ matrix.ref }}
run: |
pushd framework/examples/ios-demo
xcodegen
pod install
xcodebuild build \
-destination 'generic/platform=iOS' \
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ framework/examples/android-demo/src/main/assets/
framework/examples/android-demo/libs/*
framework/examples/android-demo/maven-auth.properties
framework/examples/android-demo/.cxx/
framework/examples/ios-demo/HippyDemo.xcodeproj
framework/examples/ios-demo/HippyDemo.xcworkspace
framework/examples/ios-demo/Pods/*
framework/examples/ios-demo/Podfile.lock
Expand Down
2 changes: 1 addition & 1 deletion .husky/post-checkout
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting '.git/hooks/post-checkout'.\n"; exit 2; }
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting the 'post-checkout' file in the hooks directory (set by 'core.hookspath'; usually '.git/hooks').\n"; exit 2; }
git lfs post-checkout "$@"
2 changes: 1 addition & 1 deletion .husky/post-commit
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting '.git/hooks/post-commit'.\n"; exit 2; }
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting the 'post-commit' file in the hooks directory (set by 'core.hookspath'; usually '.git/hooks').\n"; exit 2; }
git lfs post-commit "$@"
2 changes: 1 addition & 1 deletion .husky/post-merge
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting '.git/hooks/post-merge'.\n"; exit 2; }
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting the 'post-merge' file in the hooks directory (set by 'core.hookspath'; usually '.git/hooks').\n"; exit 2; }
git lfs post-merge "$@"
2 changes: 1 addition & 1 deletion .husky/pre-push
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting '.git/hooks/pre-push'.\n"; exit 2; }
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting the 'pre-push' file in the hooks directory (set by 'core.hookspath'; usually '.git/hooks').\n"; exit 2; }
git lfs pre-push "$@"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ For iOS, we recommend to use iOS simulator when first try. However, you can chan
3. Choose a demo to build with `npm run buildexample [hippy-react-demo|hippy-vue-demo|hippy-vue-next-demo]`.

4. Install Xcodegen with `brew install xcodegen`, install CocoaPods with `brew install cocoapods`, install cmake with `brew install cmake`, then execute `xcodegen` command at `framework/examples/ios-demo` directory, which will create `HippyDemo.xcodeproj` and `HippyDemo.xcworkspace` files and install Cocoapods dependencies.
4. Install CocoaPods with `brew install cocoapods`, install cmake with `brew install cmake`, then execute `pod install` command at `framework/examples/ios-demo` directory, which will create `HippyDemo.xcworkspace` files and install Cocoapods dependencies.

5. Start the Xcode and build the iOS app with opening `framework/examples/ios-demo/HippyDemo.xcworkspace`.

Expand Down
2 changes: 1 addition & 1 deletion docs/api/hippy-react/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ import icon from './qb_icon_new.png';
| autoHideStatusBar | 是否在`Modal`显示时自动隐藏状态栏。<strong>Android 中仅 api28 以上生效。</strong> `default: false` | `boolean` | `Android` |
| autoHideNavigationBar | 是否在`Modal`显示时自动隐藏导航栏。 `default: false` | `boolean` | `Android` |
| onShow |`Modal`显示时会执行此回调函数。 | `Function` | `Android、iOS、hippy-react-web、Web-Renderer、Voltron` |
| onOrientationChange | 屏幕旋转方向改变时执行会回调 | `Function` | `Android、iOS` |
| onOrientationChange | 屏幕旋转方向改变时执行会回调,返回当前屏幕显示方向 `{ orientation: portrait|landscape }` | `Function` | `Android、iOS` |
| onRequestClose |`Modal` 请求关闭时会执行此回调函数,一般时在 Android 系统里按下硬件返回按钮时触发,一般要在里面处理关闭弹窗。 | `Function` | `Android、hippy-react-web、Voltron` |
| transparent | 背景是否是透明的。`default: true` | `boolean` | `Android、iOS、hippy-react-web、Web-Renderer、Voltron` |
| visible | 是否显示。`default: true` | `boolean` | `Android、iOS、hippy-react-web、Web-Renderer、Voltron` |
Expand Down
2 changes: 1 addition & 1 deletion docs/development/android-3.0-integration-guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

2. Maven 集成

- 查询 [Maven Central Hippy 版本](https://search.maven.org/search?q=com.tencent.hippy),其中 `hippy-release``release` 版本(不携带 `inspector``hippy-debug``debug` 版本
- 查询 [Maven Central Hippy 版本](https://search.maven.org/search?q=com.tencent.hippy),其中 `hippy-release``release` 版本`hippy-debug``debug` 版本`hippy-snapshot``beta` 版本

- 配置 build.gradle

Expand Down
8 changes: 4 additions & 4 deletions docs/development/demo.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Demo的Native工程代码位于framework/examples目录,前端工程代码位
首先,通过Homebrew包管理工具安装git, git-lfs, node(v16) and npm(v7)

```shell
brew install git git-lfs node@16 xcodegen cmake
brew install git git-lfs node@16 cmake
```

#### 编译iOS Demo环境准备
Expand Down Expand Up @@ -82,9 +82,9 @@ git clone https://github.com/Tencent/Hippy.git
```shell
# 进入Hippy源码目录
cd ./framework/examples/ios-demo
# 执行xcodegen生成工程
xcodegen
# 打开workspace,编译运行即可
# 使用 Cocoapods 生成工程
pod install
# 打开 workspace,编译运行即可
open HippyDemo.xcworkspace
```

Expand Down
2 changes: 1 addition & 1 deletion dom/src/dom/taitank_layout_node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ TAITANK_GET_STYLE_DECL(Direction, TaitankDirection, TaitankDirection::DIRECTION_
}

static void CheckValueType(footstone::value::HippyValue::Type type) {
if (type == footstone::value::HippyValue::Type::kNumber || type == footstone::value::HippyValue::Type::kObject)
if (type == footstone::value::HippyValue::Type::kString || type == footstone::value::HippyValue::Type::kObject)
FOOTSTONE_DLOG(WARNING) << "Taitank Layout Node Value Type Error";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ export default class ModalExpo extends React.Component {
transparent={true}
animationType={this.state.animationType}
visible={visible}
onRequestClose={() => { /* Trigger when hardware back pressed */ }}
requestClose={() => { /* Trigger when hardware back pressed */ }}
orientationChange={(evt) => { console.log('orientation changed', evt.orientation); }}
supportedOrientations={['portrait']}
immersionStatusBar={this.state.immerseStatusBar}
autoHideStatusBar={this.state.hideStatusBar}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
:autoHideNavigationBar="autoHideNavigationBar"
@show="onShow"
@requestClose="onClose"
@orientationChange="onOrientationChange"
>
<!-- iOS 平台上 dialog 必须只有一个子节点 -->
<div class="dialog-demo-wrapper">
Expand Down Expand Up @@ -80,6 +81,7 @@
:autoHideStatusBar="autoHideStatusBar"
:autoHideNavigationBar="autoHideNavigationBar"
@requestClose="onClose"
@orientationChange="onOrientationChange"
>
<div
class="dialog-2-demo-wrapper center column row"
Expand Down Expand Up @@ -154,6 +156,9 @@ export default {
onShow() {
console.log('Dialog is opening');
},
onOrientationChange(evt) {
console.log('orientation changed', evt.nativeParams);
},
onClose(evt) {
evt.stopPropagation();
// Dialog 会响应硬件返回按钮,所以需要在这里关闭弹窗。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
:autoHideNavigationBar="autoHideNavigationBar"
@show="onShow"
@requestClose="onClose"
@orientationChange="onOrientationChange"
>
<!-- dialog on iOS platform can only have one child node -->
<div class="dialog-demo-wrapper">
Expand All @@ -78,6 +79,7 @@
:animationType="dialogAnimationType"
:transparent="true"
@requestClose="onClose"
@orientationChange="onOrientationChange"
>
<div
class="dialog-2-demo-wrapper center column row"
Expand Down Expand Up @@ -151,7 +153,9 @@ export default defineComponent({
const onShow = () => {
console.log('Dialog is opening');
};
const onOrientationChange = (evt) => {
console.log('orientation changed', evt.nativeParams);
};
const onClose = (evt) => {
evt.stopPropagation();
/**
Expand Down
3 changes: 2 additions & 1 deletion driver/js/include/driver/js_driver_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ class JsDriverUtils {

static std::shared_ptr<Engine> CreateEngineAndAsyncInitialize(const std::shared_ptr<TaskRunner>& task_runner,
const std::shared_ptr<VMInitParam>& param,
int64_t group_id);
int64_t group_id,
bool is_reload);

static void InitInstance(const std::shared_ptr<Engine>& engine,
const std::shared_ptr<VMInitParam>& param,
Expand Down
6 changes: 5 additions & 1 deletion driver/js/src/js_driver_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,17 @@ void AsyncInitializeEngine(const std::shared_ptr<Engine>& engine,

std::shared_ptr<Engine> JsDriverUtils::CreateEngineAndAsyncInitialize(const std::shared_ptr<TaskRunner>& task_runner,
const std::shared_ptr<VMInitParam>& param,
int64_t group_id) {
int64_t group_id,
bool is_reload) {
FOOTSTONE_DCHECK(group_id >= -1) << "group_id must be greater than or equal to -1";
std::shared_ptr<Engine> engine = nullptr;
auto group = group_id;
if (param->is_debug) {
group = VM::kDebuggerGroupId;
}
// 1. 调试模式启动新实例不复用V8 context, 调试模式 reload 场景复用 V8 context
// 2. Demo 场景, group_id 为 -1,不复用 V8 context
if ((group == VM::kDebuggerGroupId && is_reload) || (group != VM::kDebuggerGroupId && group != VM::kDefaultGroupId))
{
std::lock_guard<std::mutex> lock(engine_mutex);
auto it = reuse_engine_map.find(group);
Expand Down
1 change: 1 addition & 0 deletions driver/js/src/napi/jsc/jsc_ctx.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1149,6 +1149,7 @@ std::shared_ptr<CtxValue> JSCCtx::RunScript(const string_view& data,

if (exception) {
SetException(std::make_shared<JSCCtxValue>(context_, exception));
FOOTSTONE_LOG(ERROR) << GetExceptionMessage(exception_);
return nullptr;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ jint CreateJsDriver(JNIEnv* j_env,
jint j_dom_manager_id,
jobject j_vm_init_param,
jint j_vfs_id,
jint j_devtools_id);
jint j_devtools_id,
jboolean j_is_reload);

void DestroyJsDriver(JNIEnv* j_env,
jobject j_object,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ inline namespace driver {
REGISTER_JNI("com/openhippy/connector/JsDriver", // NOLINT(cert-err58-cpp)
"onCreate",
"([BZZZLcom/openhippy/connector/NativeCallback;"
"JILcom/openhippy/connector/JsDriver$V8InitParams;II)I",
"JILcom/openhippy/connector/JsDriver$V8InitParams;IIZ)I",
CreateJsDriver)

REGISTER_JNI("com/openhippy/connector/JsDriver", // NOLINT(cert-err58-cpp)
Expand Down Expand Up @@ -266,7 +266,8 @@ jint CreateJsDriver(JNIEnv* j_env,
jint j_dom_manager_id,
jobject j_vm_init_param,
jint j_vfs_id,
jint j_devtools_id) {
jint j_devtools_id,
jboolean j_is_reload) {
FOOTSTONE_LOG(INFO) << "CreateJsDriver begin, j_single_thread_mode = "
<< static_cast<uint32_t>(j_single_thread_mode)
<< ", j_bridge_param_json = "
Expand Down Expand Up @@ -343,7 +344,7 @@ jint CreateJsDriver(JNIEnv* j_env,
}
};
auto engine = JsDriverUtils::CreateEngineAndAsyncInitialize(
dom_task_runner, param, static_cast<int64_t>(j_group_id));
dom_task_runner, param, static_cast<int64_t>(j_group_id), static_cast<bool>(j_is_reload));
{
std::lock_guard<std::mutex> lock(holder_mutex);
engine_holder[engine.get()] = engine;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ public void onResourceReady(ByteBuffer output, long resId) {

public void initialize(byte[] globalConfig, boolean useLowMemoryMode,
boolean enableV8Serialization, boolean isDevModule, NativeCallback callback,
long groupId, int domManagerId, V8InitParams v8InitParams, int vfsId, int devtoolsId) {
long groupId, int domManagerId, V8InitParams v8InitParams, int vfsId, int devtoolsId, boolean isReload) {
mInstanceId = onCreate(globalConfig, useLowMemoryMode, enableV8Serialization,
isDevModule, callback, groupId, domManagerId, v8InitParams, vfsId, devtoolsId);
isDevModule, callback, groupId, domManagerId, v8InitParams, vfsId, devtoolsId, isReload);
}

public void onDestroy(boolean useLowMemoryMode, boolean isReload,
Expand Down Expand Up @@ -147,7 +147,7 @@ public void attachToRoot(@NonNull View root) {

private native int onCreate(byte[] globalConfig, boolean useLowMemoryMode,
boolean enableV8Serialization, boolean isDevModule, NativeCallback callback,
long groupId, int domManagerId, V8InitParams v8InitParams, int vfs_id, int devtoolsId);
long groupId, int domManagerId, V8InitParams v8InitParams, int vfs_id, int devtoolsId, boolean isReload);

private native void onDestroy(int instanceId, boolean useLowMemoryMode, boolean isReload,
NativeCallback callback);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ public void callback(Boolean result, Throwable e) {
notifyEngineInitialized(EngineInitStatus.STATUS_WRONG_STATE, e);
}
}
});
}, onReLoad);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public interface HippyBridge {
String URI_SCHEME_ASSETS = "asset:";
String URI_SCHEME_FILE = "file:";

void initJSBridge(String gobalConfig, NativeCallback callback, int groupId);
void initJSBridge(String gobalConfig, NativeCallback callback, int groupId, boolean isReload);

boolean runScriptFromUri(String uri, AssetManager assetManager, boolean canUseCodeCache,
String codeCacheTag, NativeCallback callback);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ public HippyBridgeImpl(HippyEngineContext engineContext, BridgeCallback callback
}

@Override
public void initJSBridge(String globalConfig, NativeCallback callback, final int groupId) {
public void initJSBridge(String globalConfig, NativeCallback callback, final int groupId, boolean isReload) {
mDebugGlobalConfig = globalConfig;
initJSEngine(groupId, callback);
initJSEngine(groupId, callback, isReload);
}

private void initJSEngine(int groupId, NativeCallback callback) {
private void initJSEngine(int groupId, NativeCallback callback, boolean isReload) {
synchronized (HippyBridgeImpl.class) {
try {
String localCachePath = mContext.getGlobalConfigs().getContext().getCacheDir()
Expand All @@ -112,7 +112,8 @@ private void initJSEngine(int groupId, NativeCallback callback) {
mContext.getDomManagerId(),
mV8InitParams,
mContext.getVfsId(),
mContext.getDevtoolsId()
mContext.getDevtoolsId(),
isReload
);
mInit = true;
} catch (Throwable e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
@SuppressWarnings({"deprecation", "unused"})
public interface HippyBridgeManager {

void initBridge(Callback<Boolean> callback);
void initBridge(Callback<Boolean> callback, boolean isReload);

void runBundle(int id, HippyBundleLoader loader);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import com.tencent.mtt.hippy.utils.TimeMonitor;

import java.lang.ref.WeakReference;
import java.util.HashMap;
import org.json.JSONObject;

import java.nio.ByteBuffer;
Expand Down Expand Up @@ -87,6 +88,9 @@ public enum BridgeState {
public static final int DESTROY_CLOSE = 0;
public static final int DESTROY_RELOAD = 1;

public static final int CREATE_NORMAL = 0;
public static final int CREATE_RELOAD = 1;

final HippyEngineContext mContext;
final HippyBundleLoader mCoreBundleLoader;
private final HippyBridge mHippyBridge;
Expand Down Expand Up @@ -229,6 +233,7 @@ public boolean handleMessage(Message msg) {
switch (msg.what) {
case MSG_CODE_INIT_BRIDGE: {
@SuppressWarnings("unchecked") final com.tencent.mtt.hippy.common.Callback<Boolean> callback = (com.tencent.mtt.hippy.common.Callback<Boolean>) msg.obj;
final int code = msg.arg1;
try {
mHippyBridge.initJSBridge(getGlobalConfigs(), new NativeCallback(mHandler) {
@Override
Expand Down Expand Up @@ -280,7 +285,7 @@ public void Call(long result, Message message,
callback.callback(true, null);
}
}
}, mGroupId);
}, mGroupId, code == CREATE_RELOAD);
} catch (Throwable e) {
mBridgeState = BridgeState.UNINITIALIZED;
callback.callback(false, e);
Expand Down Expand Up @@ -361,9 +366,11 @@ public void Call(long result, Message message, String action,
}

@Override
public void initBridge(Callback<Boolean> callback) {
public void initBridge(Callback<Boolean> callback, boolean isReload) {
mHandler = new Handler(mContext.getThreadExecutor().getBridgeThread().getLooper(), this);
Message message = mHandler.obtainMessage(MSG_CODE_INIT_BRIDGE, callback);
Message message = mHandler.obtainMessage(MSG_CODE_INIT_BRIDGE);
message.arg1 = isReload ? CREATE_RELOAD : CREATE_NORMAL;
message.obj = callback;
mHandler.sendMessage(message);
}

Expand Down
Loading

0 comments on commit b99a30c

Please sign in to comment.