Skip to content

Commit

Permalink
Merge remote-tracking branch 'apache/master' into core-feature-bridge
Browse files Browse the repository at this point in the history
* apache/master:
  [WEEX-527][Android] Sandbox support to debug
  * [Android] Fix animation memory leak
  * [android] Fix Iconfont issue
  Try to fix a crash operating mutable array in multi-thread
  Try to fix a crash operating mutable array in multi-thread
  [jsfm] upgrade js framework to v0.27.1 (apache#1351)
  • Loading branch information
神漠 committed Jul 24, 2018
2 parents df5af10 + a120d35 commit ea9ec00
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 48 deletions.
2 changes: 1 addition & 1 deletion android/sdk/assets/weex-main-jsfm.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion android/sdk/assets/weex-rax-api.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions android/sdk/src/main/java/com/taobao/weex/WXEnvironment.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public class WXEnvironment {
* Debug model
*/
public static boolean sDebugMode = false;
public static final boolean sForceEnableDevTool = false;
public static final boolean sForceEnableDevTool = true;
public static String sDebugWsUrl = "";
public static boolean sDebugServerConnectable = false;
public static boolean sRemoteDebugMode = false;
Expand Down Expand Up @@ -255,7 +255,7 @@ public static boolean isApkDebugable() {
*/
e.printStackTrace();
}
return false;
return true;
}

public static boolean isPerf() {
Expand Down
2 changes: 1 addition & 1 deletion android/sdk/src/main/java/com/taobao/weex/WXSDKEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ private static void register() {

registerModule("modal", WXModalUIModule.class, false);
registerModule("instanceWrap", WXInstanceWrap.class, false);
registerModule("animation", WXAnimationModule.class, true);
registerModule("animation", WXAnimationModule.class, false);
registerModule("webview", WXWebViewModule.class, true);
registerModule("navigator", WXNavigatorModule.class);
registerModule("stream", WXStreamModule.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public void setSandBoxContext(final boolean flag) {
setJSFrameworkInit(false);
WXModuleManager.resetAllModuleState();
String jsf = "";
if (!isSandBoxContext || WXEnvironment.sDebugServerConnectable) {
if (!isSandBoxContext) {
jsf = WXFileUtils.loadAsset("main.js", WXEnvironment.getApplication());
} else {
jsf = WXFileUtils.loadAsset("weex-main-jsfm.js", WXEnvironment.getApplication());
Expand All @@ -240,7 +240,7 @@ public void run() {
setJSFrameworkInit(false);
WXModuleManager.resetAllModuleState();
String jsf = "";
if (!isSandBoxContext || WXEnvironment.sDebugServerConnectable) {
if (!isSandBoxContext) {
jsf = WXFileUtils.loadAsset("main.js", WXEnvironment.getApplication());
} else {
jsf = WXFileUtils.loadAsset("weex-main-jsfm.js", WXEnvironment.getApplication());
Expand Down Expand Up @@ -1291,12 +1291,12 @@ private void invokeCreateInstance(@NonNull WXSDKInstance instance, String templa

// if { "framework": "Vue" } or { "framework": "Rax" } will use invokeCreateInstanceContext
// others will use invokeExecJS
if (!isSandBoxContext || WXEnvironment.sDebugServerConnectable) {
if (!isSandBoxContext) {
invokeExecJS(instance.getInstanceId(), null, METHOD_CREATE_INSTANCE, args, false);
return;
}
if (type == BundType.Vue || type == BundType.Rax) {
invokeCreateInstanceContext(instance.getInstanceId(), null, METHOD_CREATE_INSTANCE, args, false);
invokeCreateInstanceContext(instance.getInstanceId(), null, "createInstanceContext", args, false);
return;
} else {
invokeExecJS(instance.getInstanceId(), null, METHOD_CREATE_INSTANCE, args, false);
Expand All @@ -1315,7 +1315,7 @@ private void invokeCreateInstance(@NonNull WXSDKInstance instance, String templa
}

public WXJSObject optionObjConvert(boolean useSandBox, BundType type, WXJSObject opt) {
if (!useSandBox || type == BundType.Others || WXEnvironment.sDebugServerConnectable) {
if (!useSandBox || type == BundType.Others) {
return opt;
}
try {
Expand Down Expand Up @@ -1604,7 +1604,7 @@ private void initFramework(String framework) {
// if (WXEnvironment.isApkDebugable()) {
WXLogUtils.d("weex JS framework from assets");
// }
if (!isSandBoxContext || WXEnvironment.sDebugServerConnectable) {
if (!isSandBoxContext) {
framework = WXFileUtils.loadAsset("main.js", WXEnvironment.getApplication());
} else {
framework = WXFileUtils.loadAsset("weex-main-jsfm.js", WXEnvironment.getApplication());
Expand Down
9 changes: 7 additions & 2 deletions android/sdk/src/main/java/com/taobao/weex/utils/FontDO.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,12 @@ private void parseSrc(String src, WXSDKInstance instance) {
String base64Data = data[1];
if (!TextUtils.isEmpty(base64Data)) {
String md5 = WXFileUtils.md5(base64Data);
File tmpFile = new File(new File(WXEnvironment.getApplication().getCacheDir(), "font-family"), md5);
File cacheDir = new File(WXEnvironment.getApplication().getCacheDir(),
"font-family");
if (!cacheDir.exists()) {
cacheDir.mkdirs();
}
File tmpFile = new File(cacheDir, md5);
if(!tmpFile.exists()){
tmpFile.createNewFile();
WXFileUtils.saveFile(tmpFile.getPath(), Base64.decode(base64Data, Base64.DEFAULT), WXEnvironment.getApplication());
Expand All @@ -118,7 +123,7 @@ private void parseSrc(String src, WXSDKInstance instance) {
mState = STATE_INIT;
} catch (Exception e) {
mType = STATE_INVALID;
WXLogUtils.e("TypefaceUtil", "URI.create(mUrl) failed mUrl: " + mUrl);
WXLogUtils.e("TypefaceUtil", "URI.create(mUrl) failed mUrl: " + mUrl+ "\n"+ WXLogUtils.getStackTrace(e));
}
} else {
mUrl = src;
Expand Down
69 changes: 37 additions & 32 deletions ios/sdk/WeexSDK/Sources/Bridge/WXBridgeContext.m
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ @interface WXBridgeContext ()
//store the methods which will be executed from native to js
@property (nonatomic, strong) NSMutableDictionary *sendQueue;
//the instance stack
@property (nonatomic, strong) WXThreadSafeMutableArray *insStack;
@property (nonatomic, strong) NSMutableArray *insStack;
//identify if the JSFramework has been loaded
@property (nonatomic) BOOL frameworkLoadFinished;
//store some methods temporarily before JSFramework is loaded
Expand Down Expand Up @@ -430,19 +430,20 @@ - (NSMutableArray *)insStack
{
if (_insStack) return _insStack;

_insStack = [WXThreadSafeMutableArray array];
_insStack = [NSMutableArray array];

return _insStack;
}

- (WXSDKInstance *)topInstance
{
if (self.insStack.count > 0) {
WXSDKInstance *topInstance = [WXSDKManager instanceForID:[self.insStack firstObject]];
return topInstance;
}

return nil;
WXSDKInstance *topInstance = nil;
@synchronized(self) {
if (self.insStack.count > 0) {
topInstance = [WXSDKManager instanceForID:[self.insStack firstObject]];
}
}
return topInstance;
}

- (NSMutableDictionary *)sendQueue
Expand Down Expand Up @@ -508,14 +509,16 @@ - (void)createInstance:(NSString *)instanceIdString
{
WXAssertBridgeThread();
WXAssertParam(instanceIdString);

if (![self.insStack containsObject:instanceIdString]) {
if ([options[@"RENDER_IN_ORDER"] boolValue]) {
[self.insStack addObject:instanceIdString];
} else {
[self.insStack insertObject:instanceIdString atIndex:0];
}
}

@synchronized(self) {
if (![self.insStack containsObject:instanceIdString]) {
if ([options[@"RENDER_IN_ORDER"] boolValue]) {
[self.insStack addObject:instanceIdString];
} else {
[self.insStack insertObject:instanceIdString atIndex:0];
}
}
}

//create a sendQueue bind to the current instance
NSMutableArray *sendQueue = [NSMutableArray array];
Expand Down Expand Up @@ -676,9 +679,9 @@ - (void)destroyInstance:(NSString *)instance
WXAssertParam(instance);

//remove instance from stack
if([self.insStack containsObject:instance]){
[self.insStack removeObject:instance];
}
@synchronized(self) {
[self.insStack removeObject:instance];
}

if(_jsBridge && [_jsBridge respondsToSelector:@selector(removeTimers:)]){
[_jsBridge removeTimers:instance];
Expand Down Expand Up @@ -918,19 +921,21 @@ - (void)_sendQueueLoop
BOOL hasTask = NO;
NSMutableArray *tasks = [NSMutableArray array];
NSString *execIns = nil;

for (NSString *instance in self.insStack) {
NSMutableArray *sendQueue = self.sendQueue[instance];
if(sendQueue.count > 0){
hasTask = YES;
for(WXCallJSMethod *method in sendQueue){
[tasks addObject:[method callJSTask]];
}
[sendQueue removeAllObjects];
execIns = instance;
break;
}
}

@synchronized(self) {
for (NSString *instance in self.insStack) {
NSMutableArray *sendQueue = self.sendQueue[instance];
if(sendQueue.count > 0){
hasTask = YES;
for(WXCallJSMethod *method in sendQueue){
[tasks addObject:[method callJSTask]];
}
[sendQueue removeAllObjects];
execIns = instance;
break;
}
}
}

if ([tasks count] > 0 && execIns) {
WXSDKInstance * execInstance = [WXSDKManager instanceForID:execIns];
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "weex",
"version": "0.12.2",
"subversion": {
"framework": "0.27.0",
"framework": "0.27.1",
"transformer": ">=0.1.5 <0.5"
},
"description": "A framework for building Mobile cross-platform UI",
Expand Down
2 changes: 1 addition & 1 deletion pre-build/weex-main-jsfm.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pre-build/weex-rax-api.js

Large diffs are not rendered by default.

0 comments on commit ea9ec00

Please sign in to comment.