Skip to content

Commit

Permalink
Merge branch 'main' into hippy3_fix_3
Browse files Browse the repository at this point in the history
  • Loading branch information
open-hippy authored Oct 30, 2023
2 parents 34c6693 + f2ba451 commit 54bb29c
Show file tree
Hide file tree
Showing 17 changed files with 161 additions and 73 deletions.
11 changes: 11 additions & 0 deletions dom/src/dom/dom_node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,13 @@ std::ostream& operator<<(std::ostream& os, const RefInfo& ref_info) {
return os;
}

std::ostream& operator<<(std::ostream& os, const DiffInfo& diff_info) {
os << "{";
os << "\"skip_style_diff\": " << diff_info.skip_style_diff << ", ";
os << "}";
return os;
}

std::ostream& operator<<(std::ostream& os, const DomNode& dom_node) {
os << "{";
os << "\"id\": " << dom_node.id_ << ", ";
Expand All @@ -637,10 +644,14 @@ std::ostream& operator<<(std::ostream& os, const DomNode& dom_node) {
std::ostream& operator<<(std::ostream& os, const DomInfo& dom_info) {
auto dom_node = dom_info.dom_node;
auto ref_info = dom_info.ref_info;
auto diff_info = dom_info.diff_info;
os << "{";
if (ref_info != nullptr) {
os << "\"ref info\": " << *ref_info << ", ";
}
if (diff_info != nullptr) {
os << "\"diff info\": " << *diff_info << ", ";
}
if (dom_node != nullptr) {
os << "\"dom node\": " << *dom_node << ", ";
}
Expand Down
16 changes: 8 additions & 8 deletions dom/src/dom/root_node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ void RootNode::UpdateDomNodes(std::vector<std::shared_ptr<DomInfo>>&& nodes) {
if (!ext_update->empty()) {
diff_value->insert(ext_update->begin(), ext_update->end());
}
dom_node->SetStyleMap(node_info->dom_node->GetStyleMap());
if (!skip_style_diff) {
dom_node->SetStyleMap(node_info->dom_node->GetStyleMap());
}
dom_node->SetExtStyleMap(node_info->dom_node->GetExtStyle());
dom_node->SetDiffStyle(diff_value);

Expand Down Expand Up @@ -276,21 +278,19 @@ void RootNode::CallFunction(uint32_t id, const std::string& name, const DomArgum
}

void RootNode::SyncWithRenderManager(const std::shared_ptr<RenderManager>& render_manager) {
HP_PERF_LOG("RootNode::SyncWithRenderManager");
unsigned long cnt = dom_operations_.size();
TDF_PERF_DO_STMT_AND_LOG(unsigned long domCnt = dom_operations_.size(); , "RootNode::SyncWithRenderManager");
FlushDomOperations(render_manager);
HP_PERF_LOG("RootNode::FlushDomOperations Done, dom op count:%lld", cnt);
cnt = event_operations_.size();
TDF_PERF_DO_STMT_AND_LOG(unsigned long evCnt = event_operations_.size(); , "RootNode::FlushDomOperations Done, dom op count:%lld", domCnt);
FlushEventOperations(render_manager);
HP_PERF_LOG("RootNode::FlushEventOperations Done, event op count:%d",cnt);
TDF_PERF_LOG("RootNode::FlushEventOperations Done, event op count:%d", evCnt);
DoAndFlushLayout(render_manager);
HP_PERF_LOG("RootNode::DoAndFlushLayout Done");
TDF_PERF_LOG("RootNode::DoAndFlushLayout Done");
auto dom_manager = dom_manager_.lock();
if (dom_manager) {
dom_manager->RecordDomEndTimePoint();
}
render_manager->EndBatch(GetWeakSelf());
HP_PERF_LOG("RootNode::SyncWithRenderManager End");
TDF_PERF_LOG("RootNode::SyncWithRenderManager End");
}

void RootNode::AddEvent(uint32_t id, const std::string& event_name) {
Expand Down
2 changes: 1 addition & 1 deletion driver/js/packages/hippy-vue/src/renderer/native/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ function updateChild(parentNode, notUpdateStyle = false) {
let eventNode;
let printedNode;
if (notUpdateStyle) {
nativeNode = getNativeNode(rootViewId, parentNode, refInfo);
nativeNode = getNativeNode(rootViewId, parentNode);
} else {
[nativeNode, eventNode, printedNode] = renderToNative(rootViewId, parentNode);
}
Expand Down
6 changes: 3 additions & 3 deletions driver/js/src/modules/scene_builder_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -600,14 +600,14 @@ std::shared_ptr<ClassTemplate<SceneBuilder>> RegisterSceneBuilder(const std::wea
size_t argument_count,
const std::shared_ptr<CtxValue> arguments[],
std::shared_ptr<CtxValue>&) -> std::shared_ptr<CtxValue> {
HP_PERF_LOG("SceneBuilder.build()");
TDF_PERF_LOG("SceneBuilder.build()");
auto scope = weak_scope.lock();
if (!scope) {
HP_PERF_LOG("SceneBuilder.build() exit with error");
TDF_PERF_LOG("SceneBuilder.build() exit with error");
return nullptr;
}
SceneBuilder::Build(scope->GetDomManager(), scope->GetRootNode());
HP_PERF_LOG("SceneBuilder.build() End");
TDF_PERF_LOG("SceneBuilder.build() End");
return nullptr;
};
class_template.functions.emplace_back(std::move(build_func_def));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,22 @@ public void onFirstViewAdded() {
}
}

@Override
public void onSizeChanged(int rootId, int w, int h, int ow, int oh) {
if (mEngineContext != null) {
HippyModuleManager manager = mEngineContext.getModuleManager();
if (manager != null) {
HippyMap hippyMap = new HippyMap();
hippyMap.pushDouble("width", PixelUtil.px2dp(w));
hippyMap.pushDouble("height", PixelUtil.px2dp(h));
hippyMap.pushDouble("oldWidth", PixelUtil.px2dp(ow));
hippyMap.pushDouble("oldHeight", PixelUtil.px2dp(oh));
manager.getJavaScriptModule(EventDispatcher.class)
.receiveNativeEvent("onSizeChanged", hippyMap);
}
}
}

@Override
public void updateDimension(int width, int height, boolean shouldUseScreenDisplay,
boolean systemUiVisibilityChanged) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ class ExampleAPIProvider : HippyAPIProvider {
* register View controller for JavaScript
*/
override fun getControllers(): List<Class<out HippyViewController<*>>> {
return emptyList()
return arrayListOf(ExampleCustomPropsController::class.java)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Tencent is pleased to support the open source community by making Hippy
* available.
* Copyright (C) 2018 THL A29 Limited, a Tencent company. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.openhippy.example

import android.view.View
import com.tencent.mtt.hippy.annotation.HippyController
import com.tencent.mtt.hippy.annotation.HippyControllerProps
import com.tencent.mtt.hippy.common.HippyMap
import com.tencent.mtt.hippy.utils.LogUtils
import com.tencent.mtt.hippy.views.custom.HippyCustomPropsController

@HippyController(name = HippyCustomPropsController.CLASS_NAME)
class ExampleCustomPropsController : HippyCustomPropsController() {

val TAG = "ExampleCustomPropsController"

@HippyControllerProps(name = "pageParams", defaultType = HippyControllerProps.MAP)
fun setDtPageParams(view: View, params: HippyMap?) {
LogUtils.d(TAG, "setDtPageParams id " + view.id + ", params " + params)
}

@HippyControllerProps(name = "elementParams", defaultType = HippyControllerProps.MAP)
fun setDtElementParams(view: View, params: HippyMap?) {
LogUtils.d(TAG, "setDtElementParams id " + view.id + ", params " + params)
}
}
12 changes: 6 additions & 6 deletions framework/ios/base/bridge/HippyBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ - (instancetype)initWithDelegate:(id<HippyBridgeDelegate>)delegate
_valid = YES;
_bundlesQueue = [[HippyBundleOperationQueue alloc] init];
_startTime = footstone::TimePoint::SystemNow();
HP_PERF_LOG("HippyBridge init begin, self:%p", self);
HippyLogInfo(@"HippyBridge init begin, self:%p", self);
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(rootViewContentDidAppear:)
name:HippyContentDidAppearNotification object:nil];
HippyExecuteOnMainThread(^{
Expand All @@ -208,7 +208,7 @@ - (instancetype)initWithDelegate:(id<HippyBridgeDelegate>)delegate
[HippyBridge setCurrentBridge:self];

[self loadPendingVendorBundleURLIfNeeded];
HP_PERF_LOG("HippyBridge init end, self:%p", self);
HippyLogInfo(@"HippyBridge init end, self:%p", self);
}
return self;
}
Expand Down Expand Up @@ -414,7 +414,7 @@ - (void)loadBundleURL:(NSURL *)bundleURL
}
return;
}
HP_PERF_LOG("Begin loading bundle(%s) at %s", HP_CSTR_NOT_NULL(bundleURL.absoluteString.lastPathComponent.UTF8String), HP_CSTR_NOT_NULL(bundleURL.absoluteString.UTF8String));
HippyLogInfo(@"Begin loading bundle(%s) at %s", HP_CSTR_NOT_NULL(bundleURL.absoluteString.lastPathComponent.UTF8String), HP_CSTR_NOT_NULL(bundleURL.absoluteString.UTF8String));
[_bundleURLs addObject:bundleURL];
dispatch_async(HippyBridgeQueue(), ^{
[self beginLoadingBundle:bundleURL completion:completion];
Expand Down Expand Up @@ -452,7 +452,7 @@ - (void)beginLoadingBundle:(NSURL *)bundleURL
return;
}
[strongSelf executeJSCode:script sourceURL:bundleURL onCompletion:^(id result, NSError *error) {
HP_PERF_LOG("End loading bundle(%s) at %s", HP_CSTR_NOT_NULL(bundleURL.absoluteString.lastPathComponent.UTF8String), HP_CSTR_NOT_NULL(bundleURL.absoluteString.UTF8String));
HippyLogInfo(@"End loading bundle(%s) at %s", HP_CSTR_NOT_NULL(bundleURL.absoluteString.lastPathComponent.UTF8String), HP_CSTR_NOT_NULL(bundleURL.absoluteString.UTF8String));

if (completion) {
completion(bundleURL, error);
Expand Down Expand Up @@ -509,15 +509,15 @@ - (void)loadInstanceForRootView:(NSNumber *)rootTag withProperties:(NSDictionary
- (void)innerLoadInstanceForRootView:(NSNumber *)rootTag withProperties:(NSDictionary *)props {
HippyAssert(_moduleName, @"module name must not be null");
HippyLogInfo(@"[Hippy_OC_Log][Life_Circle],Running application %@ (%@)", _moduleName, props);
HP_PERF_LOG("Begin loading instance for HippyBridge(%p)", self);
HippyLogInfo(@"Begin loading instance for HippyBridge(%p)", self);
NSDictionary *param = @{@"name": _moduleName,
@"id": rootTag,
@"params": props ?: @{},
@"version": HippySDKVersion};
footstone::value::HippyValue value = [param toHippyValue];
std::shared_ptr<footstone::value::HippyValue> domValue = std::make_shared<footstone::value::HippyValue>(value);
self.javaScriptExecutor.pScope->LoadInstance(domValue);
HP_PERF_LOG("End loading instance for HippyBridge(%p)", self);
HippyLogInfo(@"End loading instance for HippyBridge(%p)", self);
}

- (void)rootViewSizeChangedEvent:(NSNumber *)tag params:(NSDictionary *)params {
Expand Down
16 changes: 15 additions & 1 deletion modules/footstone/include/footstone/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,21 @@ bool ShouldCreateLogMessage(LogSeverity severity);


#define HP_CSTR_NOT_NULL( p ) (p ? p : "")
#define HP_PERF_LOG(format, ...) \

#ifdef DEBUG

// enable perf log output in debug mode only
#define TDF_PERF_LOG(format, ...) \
footstone::LogMessage::LogWithFormat(__FILE_NAME__, __LINE__, "[HP PERF] " format, \
##__VA_ARGS__)

#define TDF_PERF_DO_STMT_AND_LOG( STMT , format , ...) STMT \
footstone::LogMessage::LogWithFormat(__FILE_NAME__, __LINE__, "[HP PERF] " format, \
##__VA_ARGS__)

#else

#define TDF_PERF_LOG(format, ...)
#define TDF_PERF_DO_STMT_AND_LOG(STMT , format, ...)

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import android.view.ViewTreeObserver;
import android.widget.FrameLayout;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.tencent.mtt.hippy.dom.node.NodeProps;
Expand Down Expand Up @@ -84,14 +85,12 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
}

@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
if (w != oldw || h != oldh) {
getGlobalLayoutListener().checkUpdateDimension(w, h, false, false);
NativeRender nativeRenderer = NativeRendererManager.getNativeRenderer(getContext());
if (nativeRenderer != null) {
nativeRenderer.onSizeChanged(getId(), w, h);
}
protected void onSizeChanged(int w, int h, int ow, int oh) {
super.onSizeChanged(w, h, ow, oh);
NativeRender nativeRenderer = NativeRendererManager.getNativeRenderer(getContext());
if ((w != ow || h != oh) && nativeRenderer != null) {
nativeRenderer.updateDimension(w, h, false, false);
nativeRenderer.onSizeChanged(getId(), w, h, ow, oh);
}
}

Expand Down Expand Up @@ -156,14 +155,9 @@ private void sendOrientationChangeEvent(int orientation) {

private void checkUpdateDimension(boolean shouldUseScreenDisplay,
boolean systemUiVisibilityChanged) {
checkUpdateDimension(-1, -1, shouldUseScreenDisplay, systemUiVisibilityChanged);
}

private void checkUpdateDimension(int width, int height, boolean shouldUseScreenDisplay,
boolean systemUiVisibilityChanged) {
NativeRender nativeRenderer = NativeRendererManager.getNativeRenderer(getContext());
if (nativeRenderer != null) {
nativeRenderer.updateDimension(width, height, shouldUseScreenDisplay,
nativeRenderer.updateDimension(-1, -1, shouldUseScreenDisplay,
systemUiVisibilityChanged);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@

import static com.tencent.renderer.NativeRenderException.ExceptionCode.ADD_CHILD_VIEW_FAILED_ERR;
import static com.tencent.renderer.NativeRenderException.ExceptionCode.REMOVE_CHILD_VIEW_FAILED_ERR;
import static com.tencent.renderer.NativeRenderer.SCREEN_SNAPSHOT_ROOT_ID;
import static com.tencent.renderer.node.RenderNode.FLAG_ALREADY_UPDATED;
import static com.tencent.renderer.node.RenderNode.FLAG_UPDATE_LAYOUT;

import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.openhippy.pool.BasePool.PoolType;
Expand All @@ -35,7 +33,6 @@
import com.tencent.mtt.hippy.common.HippyArray;
import com.tencent.mtt.hippy.dom.node.NodeProps;
import com.tencent.mtt.hippy.modules.Promise;
import com.tencent.mtt.hippy.utils.UIThreadUtils;
import com.tencent.mtt.hippy.views.custom.HippyCustomPropsController;
import com.tencent.mtt.hippy.views.hippylist.HippyRecyclerViewController;
import com.tencent.mtt.hippy.views.image.HippyImageViewController;
Expand All @@ -57,7 +54,6 @@
import com.tencent.mtt.hippy.views.webview.HippyWebViewController;
import com.tencent.renderer.NativeRender;
import com.tencent.renderer.NativeRenderException;
import com.tencent.renderer.NativeRendererManager;
import com.tencent.renderer.Renderer;
import com.tencent.renderer.node.RenderNode;
import com.tencent.renderer.node.VirtualNode;
Expand All @@ -71,7 +67,7 @@ public class ControllerManager {
@NonNull
private final ControllerRegistry mControllerRegistry;
@NonNull
private final ControllerUpdateManger<HippyViewController<?>, View> mControllerUpdateManger;
private final ControllerUpdateManger<HippyViewController<?>> mControllerUpdateManger;
@NonNull
private final Map<Integer, Pool<Integer, View>> mPreCreateViewPools = new HashMap<>();
@NonNull
Expand Down
Loading

0 comments on commit 54bb29c

Please sign in to comment.