You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by cx...@apache.org on 2018/06/20 11:10:24 UTC
[1/3] incubator-weex git commit: [WEEX-467][iOS] Fix multithread
issues related to transition animation.
Repository: incubator-weex
Updated Branches:
refs/heads/release 08df0d078 -> 46356993e
[WEEX-467][iOS] Fix multithread issues related to transition animation.
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/46356993
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/46356993
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/46356993
Branch: refs/heads/release
Commit: 46356993e8581e73c33bad5df0e799046f3a1d1a
Parents: d503542
Author: 神漠 <qi...@alipay.com>
Authored: Wed Jun 20 18:10:37 2018 +0800
Committer: Adam Feng <cx...@gmail.com>
Committed: Wed Jun 20 19:10:13 2018 +0800
----------------------------------------------------------------------
ios/sdk/WeexSDK/Sources/Component/WXComponent_internal.h | 5 +++++
ios/sdk/WeexSDK/Sources/Model/WXComponent.mm | 4 +++-
ios/sdk/WeexSDK/Sources/Module/WXAnimationModule.m | 2 +-
ios/sdk/WeexSDK/Sources/Module/WXTransition.mm | 9 +++++++--
ios/sdk/WeexSDK/Sources/View/WXComponent+ViewManagement.mm | 5 +++--
5 files changed, 19 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/46356993/ios/sdk/WeexSDK/Sources/Component/WXComponent_internal.h
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXComponent_internal.h b/ios/sdk/WeexSDK/Sources/Component/WXComponent_internal.h
index 5f63065..d8e2f84 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXComponent_internal.h
+++ b/ios/sdk/WeexSDK/Sources/Component/WXComponent_internal.h
@@ -152,6 +152,11 @@ typedef id (^WXDataBindingBlock)(NSDictionary *data, BOOL *needUpdate);
NSMutableDictionary<NSString *, NSArray *> *_eventParameters;
}
+/* _transform may be modified in mutiple threads. DO NOT use "_transform = XXX" directly.
+ Ivar access in ObjC is compiled to code with additional release or retain. So use Ivar in mutiple
+ thread may lead to crash. Use an ATOMIC property is well enough. */
+@property (atomic, strong) WXTransform *transform;
+
///--------------------------------------
/// @name Package Internal Methods
///--------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/46356993/ios/sdk/WeexSDK/Sources/Model/WXComponent.mm
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Model/WXComponent.mm b/ios/sdk/WeexSDK/Sources/Model/WXComponent.mm
index 58df862..d877868 100644
--- a/ios/sdk/WeexSDK/Sources/Model/WXComponent.mm
+++ b/ios/sdk/WeexSDK/Sources/Model/WXComponent.mm
@@ -69,6 +69,8 @@ static BOOL bNeedRemoveEvents = YES;
__weak WXSDKInstance *_weexInstance;
}
+@synthesize transform = _transform;
+
#pragma mark Life Cycle
- (instancetype)initWithRef:(NSString *)ref
@@ -758,7 +760,7 @@ static BOOL bNeedRemoveEvents = YES;
{
WXAssertMainThread();
- _transform = [[WXTransform alloc] initWithNativeTransform:CATransform3DMakeAffineTransform(transform) instance:self.weexInstance];
+ self.transform = [[WXTransform alloc] initWithNativeTransform:CATransform3DMakeAffineTransform(transform) instance:self.weexInstance];
if (!CGRectEqualToRect(self.calculatedFrame, CGRectZero)) {
[_transform applyTransformForView:_view];
[_layer setNeedsDisplay];
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/46356993/ios/sdk/WeexSDK/Sources/Module/WXAnimationModule.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Module/WXAnimationModule.m b/ios/sdk/WeexSDK/Sources/Module/WXAnimationModule.m
index c8afd2b..6ed9441 100644
--- a/ios/sdk/WeexSDK/Sources/Module/WXAnimationModule.m
+++ b/ios/sdk/WeexSDK/Sources/Module/WXAnimationModule.m
@@ -264,7 +264,7 @@ WX_EXPORT_METHOD(@selector(transition:args:callback:))
newInfo.toValue = @([wxTransform.translateY valueForMaximum:view.bounds.size.height]);
[infos addObject:newInfo];
}
- target->_transform = wxTransform;
+ target.transform = wxTransform;
} else if ([property isEqualToString:@"backgroundColor"]) {
info.propertyName = @"backgroundColor";
info.fromValue = (__bridge id)(layer.backgroundColor);
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/46356993/ios/sdk/WeexSDK/Sources/Module/WXTransition.mm
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Module/WXTransition.mm b/ios/sdk/WeexSDK/Sources/Module/WXTransition.mm
index 8e982ac..d185981 100644
--- a/ios/sdk/WeexSDK/Sources/Module/WXTransition.mm
+++ b/ios/sdk/WeexSDK/Sources/Module/WXTransition.mm
@@ -256,7 +256,7 @@
info.perValue = @([wxTransform.translateY floatValue] - [oldTransform.translateY floatValue]);
[_propertyArray addObject:info];
}
- _targetComponent->_transform = wxTransform;
+ _targetComponent.transform = wxTransform;
}
else
{
@@ -355,8 +355,13 @@
[_oldFilterStyles setObject:@(currentValue) forKey:info.propertyName];
}
}
+
+ /* _oldFilterStyles could be modified in current thread while _updateViewStyles uses it in main thread.
+ This may lead to crash in _updateViewStyles because the dictionary items may be retained or
+ released multiple times by code like styles[@"transform"]. So we copy _oldFilterStyles and use a duplicate.*/
+ NSDictionary* dupStyles = [NSDictionary dictionaryWithDictionary:_oldFilterStyles];
WXPerformBlockOnMainThread(^{
- [_targetComponent _updateViewStyles:_oldFilterStyles];
+ [_targetComponent _updateViewStyles:dupStyles];
});
[_targetComponent _updateCSSNodeStyles:_oldFilterStyles];
[_targetComponent.weexInstance.componentManager startComponentTasks];
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/46356993/ios/sdk/WeexSDK/Sources/View/WXComponent+ViewManagement.mm
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/View/WXComponent+ViewManagement.mm b/ios/sdk/WeexSDK/Sources/View/WXComponent+ViewManagement.mm
index 740e168..1fccb5c 100644
--- a/ios/sdk/WeexSDK/Sources/View/WXComponent+ViewManagement.mm
+++ b/ios/sdk/WeexSDK/Sources/View/WXComponent+ViewManagement.mm
@@ -252,11 +252,12 @@ do {\
}
if (styles[@"transform"]) {
id transformOrigin = styles[@"transformOrigin"] ?: self.styles[@"transformOrigin"];
- _transform = [[WXTransform alloc] initWithCSSValue:[WXConvert NSString:styles[@"transform"]] origin:[WXConvert NSString:transformOrigin] instance:self.weexInstance];
+ WXTransform* transform = [[WXTransform alloc] initWithCSSValue:[WXConvert NSString:styles[@"transform"]] origin:[WXConvert NSString:transformOrigin] instance:self.weexInstance];
if (!CGRectEqualToRect(self.calculatedFrame, CGRectZero)) {
- [_transform applyTransformForView:_view];
+ [transform applyTransformForView:_view];
[_layer setNeedsDisplay];
}
+ self.transform = transform;
}else if (styles[@"transformOrigin"]) {
[_transform setTransformOrigin:[WXConvert NSString:styles[@"transformOrigin"]]];
if (!CGRectEqualToRect(self.calculatedFrame, CGRectZero)) {
[2/3] incubator-weex git commit: *[iOS] revert statistics improvement
for weex rendering
Posted by cx...@apache.org.
*[iOS] revert statistics improvement for weex rendering
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/d503542f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/d503542f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/d503542f
Branch: refs/heads/release
Commit: d503542f38f614b364cc42b68a42b7cbc8cc9392
Parents: 16d43e6
Author: boboning <ni...@163.com>
Authored: Wed Jun 20 14:53:55 2018 +0800
Committer: Adam Feng <cx...@gmail.com>
Committed: Wed Jun 20 19:10:13 2018 +0800
----------------------------------------------------------------------
ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.mm | 2 +-
ios/sdk/WeexSDK/Sources/Monitor/WXMonitor.m | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/d503542f/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.mm
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.mm b/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.mm
index 3fa3f33..da05dd4 100644
--- a/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.mm
+++ b/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.mm
@@ -742,7 +742,7 @@ static NSThread *WXComponentThread;
[self _addUITask:^{
UIView *rootView = instance.rootView;
- //WX_MONITOR_INSTANCE_PERF_END(WXPTFirstScreenRender, instance);
+ WX_MONITOR_INSTANCE_PERF_END(WXPTFirstScreenRender, instance);
WX_MONITOR_INSTANCE_PERF_END(WXPTAllRender, instance);
WX_MONITOR_SUCCESS(WXMTJSBridge);
WX_MONITOR_SUCCESS(WXMTNativeRender);
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/d503542f/ios/sdk/WeexSDK/Sources/Monitor/WXMonitor.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Monitor/WXMonitor.m b/ios/sdk/WeexSDK/Sources/Monitor/WXMonitor.m
index 27a53b8..954d9c4 100644
--- a/ios/sdk/WeexSDK/Sources/Monitor/WXMonitor.m
+++ b/ios/sdk/WeexSDK/Sources/Monitor/WXMonitor.m
@@ -216,9 +216,9 @@ static WXThreadSafeMutableDictionary *globalPerformanceDict;
commitDict[@"instanceId"] = [instance instanceId]?:@"";
//new performance point
- if (!commitDict[SCREENRENDERTIME] && commitDict[TOTALTIME]) {
- commitDict[SCREENRENDERTIME] = commitDict[TOTALTIME];
- }
+// if (!commitDict[SCREENRENDERTIME] && commitDict[TOTALTIME]) {
+// commitDict[SCREENRENDERTIME] = commitDict[TOTALTIME];
+// }
commitDict[CALLCREATEINSTANCETIME] = commitDict[COMMUNICATETIME];
commitDict[COMMUNICATETOTALTIME] = commitDict[TOTALTIME];
[3/3] incubator-weex git commit: [WEEX-465][Android]fix performance
point interactionTime record bug
Posted by cx...@apache.org.
[WEEX-465][Android]fix performance point interactionTime record bug
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/16d43e67
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/16d43e67
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/16d43e67
Branch: refs/heads/release
Commit: 16d43e67dd04d234774240fee57b438bb6fc9490
Parents: 08df0d0
Author: zhongcang <qh...@gmail.com>
Authored: Wed Jun 20 15:04:00 2018 +0800
Committer: Adam Feng <cx...@gmail.com>
Committed: Wed Jun 20 19:10:13 2018 +0800
----------------------------------------------------------------------
.../java/com/taobao/weex/WXSDKInstance.java | 8 ++++---
.../weex/ui/action/GraphicActionAddElement.java | 4 +++-
.../ui/action/GraphicActionMoveElement.java | 5 -----
.../ui/action/GraphicActionRemoveElement.java | 9 +++++++-
.../taobao/weex/ui/component/WXComponent.java | 3 ++-
.../taobao/weex/ui/module/WXTimerModule.java | 22 ++++++--------------
6 files changed, 24 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/16d43e67/android/sdk/src/main/java/com/taobao/weex/WXSDKInstance.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/WXSDKInstance.java b/android/sdk/src/main/java/com/taobao/weex/WXSDKInstance.java
index 9f59e30..99680f7 100644
--- a/android/sdk/src/main/java/com/taobao/weex/WXSDKInstance.java
+++ b/android/sdk/src/main/java/com/taobao/weex/WXSDKInstance.java
@@ -106,6 +106,7 @@ public class WXSDKInstance implements IWXActivityStateListener,View.OnLayoutChan
//Performance
public boolean mEnd = false;
+ public boolean isJSCreateFinish =false;
public static final String BUNDLE_URL = "bundleUrl";
private IWXUserTrackAdapter mUserTrackAdapter;
private IWXRenderListener mRenderListener;
@@ -1121,6 +1122,7 @@ public class WXSDKInstance implements IWXActivityStateListener,View.OnLayoutChan
}
public void onRenderSuccess(final int width, final int height) {
+ isJSCreateFinish = true;
firstScreenRenderFinished();
long time = System.currentTimeMillis() - mRenderStartTime;
@@ -1181,10 +1183,10 @@ public class WXSDKInstance implements IWXActivityStateListener,View.OnLayoutChan
}
/**
- * when add/rm/mv element
+ * when add/rm element
*/
- public void onElementChange(){
- if (isDestroy() || !mEnd ||null == mRenderContainer || mRenderContainer.isPageHasEvent() ||
+ public void onElementChange(boolean afterJSCreateFinish){
+ if (isDestroy() || !afterJSCreateFinish ||null == mRenderContainer || mRenderContainer.isPageHasEvent() ||
mWXPerformance == null){
return;
}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/16d43e67/android/sdk/src/main/java/com/taobao/weex/ui/action/GraphicActionAddElement.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/action/GraphicActionAddElement.java b/android/sdk/src/main/java/com/taobao/weex/ui/action/GraphicActionAddElement.java
index c73e704..5aa7b61 100644
--- a/android/sdk/src/main/java/com/taobao/weex/ui/action/GraphicActionAddElement.java
+++ b/android/sdk/src/main/java/com/taobao/weex/ui/action/GraphicActionAddElement.java
@@ -39,6 +39,7 @@ public class GraphicActionAddElement extends GraphicActionAbstractAddElement {
private WXComponent child;
private GraphicPosition layoutPosition;
private GraphicSize layoutSize;
+ private boolean isJSCreateFinish = false;
public GraphicActionAddElement(String pageId, String ref,
String componentType, String parentRef,
@@ -72,6 +73,7 @@ public class GraphicActionAddElement extends GraphicActionAbstractAddElement {
mParentRef);
child = createComponent(instance, parent, basicComponentData);
child.setTransition(WXTransition.fromMap(child.getStyles(), child));
+ isJSCreateFinish = instance.isJSCreateFinish;
if (child == null || parent == null) {
return;
@@ -122,7 +124,7 @@ public class GraphicActionAddElement extends GraphicActionAbstractAddElement {
child.bindData(child);
WXSDKInstance instance = WXSDKManager.getInstance().getWXRenderManager().getWXSDKInstance(getPageId());
if (null!=instance){
- instance.onElementChange();
+ instance.onElementChange(isJSCreateFinish);
// instance.setma
}
} catch (Exception e) {
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/16d43e67/android/sdk/src/main/java/com/taobao/weex/ui/action/GraphicActionMoveElement.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/action/GraphicActionMoveElement.java b/android/sdk/src/main/java/com/taobao/weex/ui/action/GraphicActionMoveElement.java
index 3cec87c..ac6474b 100644
--- a/android/sdk/src/main/java/com/taobao/weex/ui/action/GraphicActionMoveElement.java
+++ b/android/sdk/src/main/java/com/taobao/weex/ui/action/GraphicActionMoveElement.java
@@ -18,7 +18,6 @@
*/
package com.taobao.weex.ui.action;
-import com.taobao.weex.WXSDKInstance;
import com.taobao.weex.WXSDKManager;
import com.taobao.weex.ui.component.WXComponent;
import com.taobao.weex.ui.component.WXVContainer;
@@ -49,9 +48,5 @@ public class GraphicActionMoveElement extends BasicGraphicAction {
if (!component.isVirtualComponent()) {
((WXVContainer) newParent).addSubView(component.getHostView(), mIndex);
}
- WXSDKInstance instance = WXSDKManager.getInstance().getWXRenderManager().getWXSDKInstance(getPageId());
- if (null!=instance){
- instance.onElementChange();
- }
}
}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/16d43e67/android/sdk/src/main/java/com/taobao/weex/ui/action/GraphicActionRemoveElement.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/action/GraphicActionRemoveElement.java b/android/sdk/src/main/java/com/taobao/weex/ui/action/GraphicActionRemoveElement.java
index 2b24eab..11ff2e0 100644
--- a/android/sdk/src/main/java/com/taobao/weex/ui/action/GraphicActionRemoveElement.java
+++ b/android/sdk/src/main/java/com/taobao/weex/ui/action/GraphicActionRemoveElement.java
@@ -25,8 +25,15 @@ import com.taobao.weex.ui.component.WXVContainer;
public class GraphicActionRemoveElement extends BasicGraphicAction {
+ private boolean isJSCreateFinish = false;
+
public GraphicActionRemoveElement(String pageId, String ref) {
super(pageId, ref);
+ WXSDKInstance instance = WXSDKManager.getInstance().getWXRenderManager().getWXSDKInstance(getPageId());
+ if (null != instance){
+ isJSCreateFinish = instance.isJSCreateFinish;
+ }
+
}
@Override
@@ -55,7 +62,7 @@ public class GraphicActionRemoveElement extends BasicGraphicAction {
}
WXSDKInstance instance = WXSDKManager.getInstance().getWXRenderManager().getWXSDKInstance(getPageId());
if (null!=instance){
- instance.onElementChange();
+ instance.onElementChange(isJSCreateFinish);
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/16d43e67/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponent.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponent.java b/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponent.java
index 072d8f4..3851c1b 100644
--- a/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponent.java
+++ b/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponent.java
@@ -85,6 +85,7 @@ import com.taobao.weex.ui.animation.WXAnimationBean;
import com.taobao.weex.ui.animation.WXAnimationModule;
import com.taobao.weex.ui.component.basic.WXBasicComponent;
import com.taobao.weex.ui.component.binding.Statements;
+import com.taobao.weex.ui.component.list.WXCell;
import com.taobao.weex.ui.component.list.template.jni.NativeRenderObjectUtils;
import com.taobao.weex.ui.component.pesudo.OnActivePseudoListner;
import com.taobao.weex.ui.component.pesudo.PesudoStatus;
@@ -929,7 +930,7 @@ public abstract class WXComponent<T extends View> extends WXBasicComponent imple
return;
}
- if (realHeight >= WXPerformance.VIEW_LIMIT_HEIGHT && realWidth>=WXPerformance.VIEW_LIMIT_WIDTH){
+ if (this instanceof WXCell && realHeight >= WXPerformance.VIEW_LIMIT_HEIGHT && realWidth>=WXPerformance.VIEW_LIMIT_WIDTH){
mInstance.getWXPerformance().cellExceedNum++;
}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/16d43e67/android/sdk/src/main/java/com/taobao/weex/ui/module/WXTimerModule.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/module/WXTimerModule.java b/android/sdk/src/main/java/com/taobao/weex/ui/module/WXTimerModule.java
index de5a135..d2c711a 100644
--- a/android/sdk/src/main/java/com/taobao/weex/ui/module/WXTimerModule.java
+++ b/android/sdk/src/main/java/com/taobao/weex/ui/module/WXTimerModule.java
@@ -69,14 +69,9 @@ public class WXTimerModule extends WXModule implements Destroyable, Handler.Call
public void setTimeout(@IntRange(from = 1) int funcId, @FloatRange(from = 0) float delay) {
if(mWXSDKInstance != null) {
postOrHoldMessage(MODULE_TIMEOUT, funcId, (int) delay, WXUtils.parseInt(mWXSDKInstance.getInstanceId()));
- WXSDKManager.getInstance().postOnUiThread(new Runnable() {
- @Override
- public void run() {
- if (null != mWXSDKInstance){
- mWXSDKInstance.getWXPerformance().timerInvokeCount++;
- }
- }
- },0);
+ if (null != mWXSDKInstance.getWXPerformance()){
+ mWXSDKInstance.getWXPerformance().timerInvokeCount++;
+ }
}
}
@@ -84,14 +79,9 @@ public class WXTimerModule extends WXModule implements Destroyable, Handler.Call
public void setInterval(@IntRange(from = 1) int funcId, @FloatRange(from = 0) float interval) {
if(mWXSDKInstance != null) {
postOrHoldMessage(MODULE_INTERVAL, funcId, (int) interval, WXUtils.parseInt(mWXSDKInstance.getInstanceId()));
- WXSDKManager.getInstance().postOnUiThread(new Runnable() {
- @Override
- public void run() {
- if (null != mWXSDKInstance){
- mWXSDKInstance.getWXPerformance().timerInvokeCount++;
- }
- }
- },0);
+ if (null != mWXSDKInstance.getWXPerformance()){
+ mWXSDKInstance.getWXPerformance().timerInvokeCount++;
+ }
}
}