incubator-weex icon indicating copy to clipboard operation
incubator-weex copied to clipboard

[Android]White Screen onRenderError -1001,degradeToH5|createInstance fail|wx_create_instance_error isJSFrameworkInit==false reInitCount == 1 when a weex page creating where weex version is 0.28.0

Open FightingForDevelop opened this issue 5 years ago • 12 comments

My project occurs white screen now and then.But it reproduces difficultily.And I check source codes finding that it execute in Child Thread.Even if it didn't occur in old version.

`private static void doInitInternal(final Application application, final InitConfig config) { WXEnvironment.sApplication = application; if (application == null) { WXLogUtils.e("WXSDKEngine", " doInitInternal application is null"); WXExceptionUtils.commitCriticalExceptionRT((String)null, WXErrorCode.WX_KEY_EXCEPTION_SDK_INIT, "doInitInternal", WXErrorCode.WX_KEY_EXCEPTION_SDK_INIT.getErrorMsg() + "WXEnvironment sApplication is null", (Map)null); }

    WXEnvironment.JsFrameworkInit = false;
    WXBridgeManager.getInstance().postWithName(new Runnable() {
        public void run() {
            long start = System.currentTimeMillis();
            WXSDKManager sm = WXSDKManager.getInstance();
            sm.onSDKEngineInitialize();
            if (config != null) {
                sm.setInitConfig(config);
            }

            WXSoInstallMgrSdk.init(application, sm.getIWXSoLoaderAdapter(), sm.getWXStatisticsListener());
            IWXUserTrackAdapter userTrackAdapter = config != null ? config.getUtAdapter() : null;
            int version = true;
            WXSDKEngine.mIsSoInit = WXSoInstallMgrSdk.initSo("weexcore", 1, userTrackAdapter);
            WXSoInstallMgrSdk.copyJssRuntimeSo();
            if (config != null) {
                Iterator var6 = config.getNativeLibraryList().iterator();

                while(var6.hasNext()) {
                    String libraryName = (String)var6.next();
                    WXSoInstallMgrSdk.initSo(libraryName, 1, userTrackAdapter);
                }
            }

            if (!WXSDKEngine.mIsSoInit) {
                WXExceptionUtils.commitCriticalExceptionRT((String)null, WXErrorCode.WX_KEY_EXCEPTION_SDK_INIT, "doInitInternal", WXErrorCode.WX_KEY_EXCEPTION_SDK_INIT.getErrorMsg() + "isSoInit false", (Map)null);
            } else {
                sm.initScriptsFramework(config != null ? config.getFramework() : null);
                WXEnvironment.sSDKInitExecuteTime = System.currentTimeMillis() - start;
                WXLogUtils.renderPerformanceLog("SDKInitExecuteTime", WXEnvironment.sSDKInitExecuteTime);
            }
        }
    }, (WXSDKInstance)null, "doInitWeexSdkInternal");
    WXStateRecord.getInstance().startJSThreadWatchDog();
    register();
}`

So I annotate "WXSDKEngine.initialize(BaseApplication.app, con);" to simulate error -1001.And in Method"onException" catching the errCode,I reinitialize and reload the page,then it works.I want to affirm if it reasonable or not. Looking forward to your reply!

FightingForDevelop avatar Jan 10 '20 13:01 FightingForDevelop

you can edit your build.gradle in app such as ndk:

ndk {
            abiFilters "x86"
            abiFilters "arm64-v8a"
            abiFilters "armeabi-v7a"
 }

AIDeepx avatar Jan 19 '20 00:01 AIDeepx

@FightingForDevelop You remove init, and everything went well?

That's very unlikely.

YorkShen avatar Feb 04 '20 10:02 YorkShen

you can edit your build.gradle in app such as ndk:

ndk {
            abiFilters "x86"
            abiFilters "arm64-v8a"
            abiFilters "armeabi-v7a"
 }

I have added it,it isn't the resone. ndk { abiFilters "armeabi-v7a", "x86" }

FightingForDevelop avatar Feb 04 '20 10:02 FightingForDevelop

@FightingForDevelop You remove init, and everything went well?

That's very unlikely.

No,no,I just simulate the error to locate the problem.I find that White Screen onRenderError -1001 because it hasn't finished initialize.So I initialize it again the page onException by code -1001. How can I know when it's initialized and then load the page?

FightingForDevelop avatar Feb 04 '20 11:02 FightingForDevelop

Same problem.

-1001:degradeToH5|createInstance fail|wx_create_instance_error[WXBridgeManager] invokeCreateInstance

tuoxie007 avatar Mar 16 '20 06:03 tuoxie007

onRenderError -1001,degradeToH5|createInstance fail|wx_create_instance_error isJSFrameworkInit==false reInitCount == 1

 ndk {
            abiFilters "x86"
            abiFilters "arm64-v8a"
            abiFilters "armeabi-v7a"
        }
  implementation 'com.alibaba:fastjson:1.1.46.android'
    implementation 'org.apache.weex:sdk:0.28.0'

XBYoung avatar May 07 '20 07:05 XBYoung

ni shi chinese?直接用中文

AIDeepx avatar Jun 23 '20 01:06 AIDeepx

ni shi chinese?直接用中文

And you?

FightingForDevelop avatar Jun 23 '20 02:06 FightingForDevelop

你现在还是白屏吗?weex应该都是我们自己人在用吧! 白屏我遇到过很多问题,主要还是代码有问题,所以还是直接吧完整的代码贴出来,好一点

AIDeepx avatar Jun 23 '20 02:06 AIDeepx

` @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (mWXSDKInstance != null) { mWXSDKInstance.onActivityCreate(); } }

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { loadJsBundle(); } public void loadJsBundle() { activityContext = getActivityContext(); showLoading(); if (mWXSDKInstance != null) { mWXSDKInstance.registerRenderListener(null); mWXSDKInstance.destroy(); mWXSDKInstance = null; } mWXSDKInstance = new WXSDKInstance(activityContext); mWXSDKInstance.registerRenderListener(this); }` 现在是这样处理的,我在IWXRenderListener的onException检测到异常会再次调用loadJsBundle()知道页面展示出来

FightingForDevelop avatar Jun 23 '20 02:06 FightingForDevelop

我是在activity页面这样写的

private void syncSDKInit(final String RenderPageUrl) {
        if (!WXSDKEngine.isInitialized()) {
            mTipView.postDelayed(new Runnable() {
                @Override
                public void run() {
                    syncSDKInit(RenderPageUrl);
                }
            }, 100);
        } else {
            jumpPage(RenderPageUrl);
        }
    }

AIDeepx avatar Jun 23 '20 02:06 AIDeepx

我是在activity页面这样写的

private void syncSDKInit(final String RenderPageUrl) {
        if (!WXSDKEngine.isInitialized()) {
            mTipView.postDelayed(new Runnable() {
                @Override
                public void run() {
                    syncSDKInit(RenderPageUrl);
                }
            }, 100);
        } else {
            jumpPage(RenderPageUrl);
        }
    }

这样写应该会好一点,我试一下,多谢

FightingForDevelop avatar Jun 23 '20 03:06 FightingForDevelop