Skip to content

Commit

Permalink
[WEEX-551][core][Android] Add new new data render mode. (#1409)
Browse files Browse the repository at this point in the history
* [core] init vnode & ast interface

* [core] add basic code generator

* [core] Add vnode for data-render

* [core] Add basic VM and ExecState

* add ast source code

* [core] Add StringTable and support string value

* fix compile issue

* [core] opcode implement

* [core] code generator implement

* [core] int to int64 & opcode implement

* [core]VM init in VNodeRenderManager

* [core]support createElement and appendChild

* [core] remove android log

* [core]fix vnode_manager compile error

* [core]prototype test

* [core] support childblockstatement visit

* [core]Add setAttr support, fix chunk ast parse

* [core]fix create element args error

* rename ast constant,add assignment

* code optimize  and parsing using stacks

* [core] LT LE JMP opcode implement

* [core] opcode implement

* [core] LT LE JMP opcode implement

* pasing if for statement

* [core] Support global variables getter

* [core] Add time log for data_render, add setClassList support, fix parser error.

* [core]fix setClassList issue

* [core] add op_code OP_GOTO

* [core] OP_GOTO opcode implement

* [core] for and if statement implement

* [core] assign expression implement

* [core] op_code increment & decrement implement

* [core] Add bool and double AST

* [core] op_code increment & decrement implement

* [core] prefix expression implement & fix value copy construction

* [core] Add VNodeRenderContext, move context code from exec_state.

* [core] [data_render] support c_ptr value

* [core] Fixed crash and paser name error

* [core] add test workspace

* Revert "[core] add test workspace"

This reverts commit e235e990dfd34fefe9a4978e7e22d3a08f97c380.

* [core] boolean constant & double constant code generator

* [core]fix compile

* [core]using expression parser for match and binding in parser.cc

* [core] declaration list code generator

* [core] op_code table implement

* [core] op_code table implement

* [core] modify cmakelist file

* [core][data_render] fix compile error & format code

* [core] op_code table_factory && bug fix

* [core]remove statistic and parse_context, fix code style

* [core]Add "data" parse to global var.

* [core] using sizeof while parsing for,'match' got higher priority , improve parser code style.

* [core][Android] optimize renderobject to component link.

A continuous optimization process.

1. Use creator for list and cell component to avoid reflection
2. Add useScroller field to avoid using set to store used types
 in a instance
3. Use WXSDKInstance instead of instanceId to avoid map search
4. Use JNIEnv::NewStringUTF instead of using cache

* [core]Add refresh and close test for data_render. Add a test activity in playground

* [core] member access & array constant & object constant code generator

* [core] gettable op_code bugfix

* [core] add local c function (sizeof, log)

* [core][Android] remove MeasureMode_jni, optimize text layout

* [core] add local function gettablesize

* [core] Table lifecycle management & avoid [new] operate

* [core]  json array size bugfix & set table value bugfix

* [core] add constructor for VNodeRenderContext

* [core] String add operation

* [core]Fix for statement and if statement parse, remove extra json

* [core] use VNode* value instead of id and tag

* [core] remove useless code & format

* [core] function prototype implement

* [core]Add support for component. Add merge function. Add CommaExpression. Fix AssignExpression opcode. Fix ForStatement alias update problem. Fix GETTABLE opcode bug. Add ReturnStatement opcode generation and vm support. Add OP_INVALID VM support, TBD.

* [core] Making function in chunk global, Fix component call, Fix ObjectConstant

* [core]Using this to emulate class-field behavior

* [core] string factory release

* [core] use unique_ptr to manage pointer

* [core] fix opcode ABC overflow problem add ABx and Ax

In addition:
1.Parser result should return copy one.
2.RenderSuccess is called by UI thread, do not need to post action.
3.Others

* [core] Add Render Strategy DATA_RENDER

1. fix crash when exit page.
2. fix refresh init_data not working bug

* [core] move json11 to third_party

* [core] rm non-use file

* [core]Add appendUrlParam func

* [core] add tostring cfunc

* [core] update so

* [core]fix type convert of ValueLT...; fix refresh process.

* [core] fix WeexProxy NPE

* [core] update weexcore.so

* [core] fix sequential problem

* [core] fix weexproxy npe

* [core] Add so initialize protection, fix jni_onload error
  • Loading branch information
yxping authored and YorkShen committed Aug 9, 2018
1 parent 42046b0 commit f9c31c5
Show file tree
Hide file tree
Showing 104 changed files with 8,955 additions and 391 deletions.
1 change: 1 addition & 0 deletions android/playground/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ under the License.
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/filepaths" />
</provider>

</application>

</manifest>
Binary file removed android/sdk/libs/x86/libweexcore.so
Binary file not shown.
32 changes: 27 additions & 5 deletions android/sdk/src/main/java/com/taobao/weex/WXSDKEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public class WXSDKEngine implements Serializable {
public static final String JS_FRAMEWORK_RELOAD="js_framework_reload";
private static final String V8_SO_NAME = CORE_SO_NAME;
private volatile static boolean mIsInit = false;
private volatile static boolean mIsSoInit = false;
private static final Object mLock = new Object();
private static final String TAG = "WXSDKEngine";

Expand Down Expand Up @@ -144,6 +145,12 @@ public static boolean isInitialized(){
}
}

public static boolean isSoInitialized(){
synchronized(mLock) {
return mIsSoInit;
}
}

/**
*
* @param application
Expand Down Expand Up @@ -215,14 +222,13 @@ public void run() {
WXSoInstallMgrSdk.init(application,
sm.getIWXSoLoaderAdapter(),
sm.getWXStatisticsListener());
boolean isSoInitSuccess = WXSoInstallMgrSdk.initSo(V8_SO_NAME, 1, config!=null?config.getUtAdapter():null);
if (!isSoInitSuccess) {
mIsSoInit = WXSoInstallMgrSdk.initSo(V8_SO_NAME, 1, config!=null?config.getUtAdapter():null);
if (!mIsSoInit) {
WXExceptionUtils.commitCriticalExceptionRT(null,
WXErrorCode.WX_KEY_EXCEPTION_SDK_INIT,
"doInitInternal",
WXErrorCode.WX_KEY_EXCEPTION_SDK_INIT.getErrorMsg() + "isSoInit false",
null);

return;
}
sm.initScriptsFramework(config!=null?config.getFramework():null);
Expand Down Expand Up @@ -305,12 +311,28 @@ private static void register() {
true,
WXBasicComponentType.SLIDER_NEIGHBOR
);
registerComponent(
new SimpleComponentHolder(
WXCell.class,
new WXCell.Creator()
),
true,
WXBasicComponentType.CELL);
registerComponent(
new SimpleComponentHolder(
WXListComponent.class,
new WXListComponent.Creator()
),
true,
WXBasicComponentType.LIST,
WXBasicComponentType.VLIST,
WXBasicComponentType.RECYCLER,
WXBasicComponentType.WATERFALL);

String simpleList = "simplelist";
registerComponent(SimpleListComponent.class,false,simpleList);
registerComponent(WXListComponent.class, false,WXBasicComponentType.LIST,WXBasicComponentType.VLIST,WXBasicComponentType.RECYCLER,WXBasicComponentType.WATERFALL);
registerComponent(WXRecyclerTemplateList.class, false,WXBasicComponentType.RECYCLE_LIST);
registerComponent(HorizontalListComponent.class,false,WXBasicComponentType.HLIST);
registerComponent(WXBasicComponentType.CELL, WXCell.class, true);
registerComponent(WXBasicComponentType.CELL_SLOT, WXCell.class, true);
registerComponent(WXBasicComponentType.INDICATOR, WXIndicator.class, true);
registerComponent(WXBasicComponentType.VIDEO, WXVideo.class, false);
Expand Down
71 changes: 27 additions & 44 deletions android/sdk/src/main/java/com/taobao/weex/WXSDKInstance.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ public class WXSDKInstance implements IWXActivityStateListener,View.OnLayoutChan
private boolean enableLayerType = true;
private boolean mNeedValidate = false;
private boolean mNeedReLoad = false;
private boolean mUseScroller = false;
private int mInstanceViewPortWidth = 750;
private WXInstanceApm mApmForInstance;
private @NonNull
Expand Down Expand Up @@ -331,6 +332,14 @@ public void setNeedLoad(boolean load) {
mNeedReLoad = load;
}

public boolean isUseScroller() {
return mUseScroller;
}

public void setUseScroller(boolean use) {
mUseScroller = use;
}

public void setInstanceViewPortWidth(int instanceViewPortWidth) {
this.mInstanceViewPortWidth = instanceViewPortWidth;
}
Expand Down Expand Up @@ -952,8 +961,7 @@ public boolean onCreateOptionsMenu(Menu menu) {
public void onActivityPause() {
onViewDisappear();
if(!isCommit){
Set<String> componentTypes= WXComponentFactory.getComponentTypesByInstanceId(getInstanceId());
if(componentTypes!=null && componentTypes.contains(WXBasicComponentType.SCROLLER)){
if(mUseScroller){
mWXPerformance.useScroller=1;
}
mWXPerformance.maxDeepViewLayer=getMaxDeepLayer();
Expand Down Expand Up @@ -1142,22 +1150,14 @@ public void onViewAppear(){

public void onCreateFinish() {
if (mContext != null) {
runOnUiThread(new Runnable() {

@Override
public void run() {
if ( mContext != null) {
onViewAppear();
View wxView= mRenderContainer;
if(mRenderListener != null) {
mRenderListener.onViewCreated(WXSDKInstance.this, wxView);
}
if (mStatisticsListener != null) {
mStatisticsListener.onFirstView();
}
}
}
});
onViewAppear();
View wxView= mRenderContainer;
if(mRenderListener != null) {
mRenderListener.onViewCreated(WXSDKInstance.this, wxView);
}
if (mStatisticsListener != null) {
mStatisticsListener.onFirstView();
}
}
}

Expand Down Expand Up @@ -1195,23 +1195,15 @@ public void onRenderSuccess(final int width, final int height) {
WXLogUtils.d(WXLogUtils.WEEX_PERF_TAG, "mComponentNum:" + mWXPerformance.componentCount);

if (mRenderListener != null && mContext != null) {
runOnUiThread(new Runnable() {

@Override
public void run() {
if (mRenderListener != null && mContext != null) {
mRenderListener.onRenderSuccess(WXSDKInstance.this, width, height);
if (mUserTrackAdapter != null) {
WXPerformance performance=new WXPerformance(mInstanceId);
performance.errCode=WXErrorCode.WX_SUCCESS.getErrorCode();
performance.args=getBundleUrl();
mUserTrackAdapter.commit(mContext,null,IWXUserTrackAdapter.JS_BRIDGE,performance,getUserTrackParams());
}
mRenderListener.onRenderSuccess(WXSDKInstance.this, width, height);
if (mUserTrackAdapter != null) {
WXPerformance performance=new WXPerformance(mInstanceId);
performance.errCode=WXErrorCode.WX_SUCCESS.getErrorCode();
performance.args=getBundleUrl();
mUserTrackAdapter.commit(mContext,null,IWXUserTrackAdapter.JS_BRIDGE,performance,getUserTrackParams());
}

WXLogUtils.d(WXLogUtils.WEEX_PERF_TAG, mWXPerformance.toString());
}
}
});
WXLogUtils.d(WXLogUtils.WEEX_PERF_TAG, mWXPerformance.toString());
}
if(!WXEnvironment.isApkDebugable()){
WXLogUtils.e("weex_perf",mWXPerformance.getPerfData());
Expand All @@ -1221,15 +1213,7 @@ public void run() {
public void onRefreshSuccess(final int width, final int height) {
WXLogUtils.renderPerformanceLog("onRefreshSuccess", (System.currentTimeMillis() - mRefreshStartTime));
if (mRenderListener != null && mContext != null) {
runOnUiThread(new Runnable() {

@Override
public void run() {
if (mRenderListener != null && mContext != null) {
mRenderListener.onRefreshSuccess(WXSDKInstance.this, width, height);
}
}
});
mRenderListener.onRefreshSuccess(WXSDKInstance.this, width, height);
}
}

Expand Down Expand Up @@ -1414,7 +1398,6 @@ public synchronized void destroy() {
if(mRendered) {
WXSDKManager.getInstance().destroyInstance(mInstanceId);
}
WXComponentFactory.removeComponentTypesByInstanceId(getInstanceId());

if (mGlobalEventReceiver != null) {
getContext().unregisterReceiver(mGlobalEventReceiver);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public class WXBridge implements IWXBridge {

private native int nativeInitFramework(String framework, WXParams params);

private native void nativeRefreshInstance(String instanceId, String namespace, String function, WXJSObject[] args);

private native int nativeExecJS(String instanceId, String name, String function, WXJSObject[] args);

private native int nativeExecJSService(String javascript);
Expand Down Expand Up @@ -116,6 +118,11 @@ public int initFrameworkEnv(String framework, WXParams params, String cacheDir,
}
}

@Override
public void refreshInstance(String instanceId, String namespace, String function, WXJSObject[] args) {
nativeRefreshInstance(instanceId, namespace, function, args);
}

@Override
public int execJS(String instanceId, String namespace, String function, WXJSObject[] args) {
return nativeExecJS(instanceId, namespace, function, args);
Expand Down
Loading

0 comments on commit f9c31c5

Please sign in to comment.