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:59:20 UTC
incubator-weex git commit: [WEEX-468][iOS] Try to fix Fixed component
related crash.
Repository: incubator-weex
Updated Branches:
refs/heads/master 35e61d9b5 -> 060c5905c
[WEEX-468][iOS] Try to fix Fixed component related crash.
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/060c5905
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/060c5905
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/060c5905
Branch: refs/heads/master
Commit: 060c5905c8c338147d6bacf5fbba049c110b4147
Parents: 35e61d9
Author: Xiaomin <ca...@yahoo.com>
Authored: Wed Jun 20 19:47:45 2018 +0800
Committer: Xiaomin <ca...@yahoo.com>
Committed: Wed Jun 20 19:47:45 2018 +0800
----------------------------------------------------------------------
ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.mm | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/060c5905/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 da05dd4..67d1c7a 100644
--- a/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.mm
+++ b/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.mm
@@ -64,6 +64,8 @@ static NSThread *WXComponentThread;
NSMutableArray *_fixedComponents;
WeexCore::WXCoreLayoutNode* _rootFlexCSSNode;
CADisplayLink *_displayLink;
+ pthread_mutex_t _propertyMutex;
+ pthread_mutexattr_t _propertMutexAttr;
}
+ (instancetype)sharedManager
@@ -85,6 +87,9 @@ static NSThread *WXComponentThread;
_fixedComponents = [NSMutableArray wx_mutableArrayUsingWeakReferences];
_uiTaskQueue = [NSMutableArray array];
_isValid = YES;
+ pthread_mutexattr_init(&_propertMutexAttr);
+ pthread_mutexattr_settype(&_propertMutexAttr, PTHREAD_MUTEX_RECURSIVE);
+ pthread_mutex_init(&_propertyMutex, &_propertMutexAttr);
[self _startDisplayLink];
}
@@ -102,6 +107,8 @@ static NSThread *WXComponentThread;
_rootFlexCSSNode=nullptr;
}
[NSMutableArray wx_releaseArray:_fixedComponents];
+ pthread_mutex_destroy(&_propertyMutex);
+ pthread_mutexattr_destroy(&_propertMutexAttr);
}
#pragma mark Thread Management
@@ -979,13 +986,17 @@ static NSThread *WXComponentThread;
- (void)addFixedComponent:(WXComponent *)fixComponent
{
+ pthread_mutex_lock(&_propertyMutex);
[_fixedComponents addObject:fixComponent];
- _rootFlexCSSNode->addChildAt(fixComponent.flexCssNode, (uint32_t)([_fixedComponents count]-1));
+ _rootFlexCSSNode->addChildAt(fixComponent.flexCssNode, (uint32_t)([_fixedComponents count]-1));
+ pthread_mutex_unlock(&_propertyMutex);
}
- (void)removeFixedComponent:(WXComponent *)fixComponent
{
+ pthread_mutex_lock(&_propertyMutex);
[_fixedComponents removeObject:fixComponent];
+ pthread_mutex_unlock(&_propertyMutex);
[self removeFixFlexNode:fixComponent->_flexCssNode];
}