Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用devtools在线调试会导致实例被destory,同时JS FRAMEWORK被启动多次,导致程序无法运行的bug #48

Open
hupanfeng opened this issue May 27, 2017 · 7 comments

Comments

@hupanfeng
Copy link

我在自己的程序里出现这个问题后,又用官方提供的示例程序(hackernews)调试,都出现了这个问题。

  1. 修改build.gradle:
    compile 'com.taobao.android:weex_sdk:0.11.0'
    //compile project(':weex_sdk')
    compile 'com.taobao.android:weex_inspector:0.10.0.5'
    compile 'com.squareup.okhttp:okhttp:2.3.0'
    compile 'com.squareup.okhttp:okhttp-ws:2.3.0'
    compile 'com.squareup.okio:okio:1.0.1'
    2、修改WXApplication:
    public class WXApplication extends Application {

    @OverRide
    public void onCreate() {
    super.onCreate();
    initDebugEnvironment(true, "192.168.1.107");
    InitConfig config=new InitConfig.Builder().setImgAdapter(new ImageAdapter()).build();
    WXSDKEngine.initialize(this,config);
    }

    private void initDebugEnvironment(boolean enable, String host) {
    WXEnvironment.sRemoteDebugMode = enable;
    WXEnvironment.sRemoteDebugProxyUrl = "ws://" + host + ":8088/debugProxy/native";
    }
    }
    3、错误日志如下:
    image

@misakuo
Copy link
Member

misakuo commented May 27, 2017

devtools调试的原理决定了在连接devtools后必须要重新初始化JS Framework并且重新创建Instance

@hupanfeng
Copy link
Author

也就是说我得等到JS Framework重新初始化后再手动的创建instance?

@tonyyls
Copy link

tonyyls commented Nov 7, 2017

遇到同样的问题,求官方给予指引,谢谢

@mario-huang
Copy link

@misakuo 连接devtools后重新初始化JS Framework这没有问题。
但是!修改了weex代码(热刷新),也导致了WXSDKEngine.reload();
结果整个debug页面被刷新,所有log都来不及显示,之后也不再显示了。
iOS没有这个问题。

@mario-huang
Copy link

mario-huang commented Nov 7, 2018

热刷新跑到了这里

@ChromeDevtoolsMethod
    public void reload(JsonRpcPeer peer, JSONObject params) {
        WXLogUtils.e("WxDebug-new >>>> reload=" + params);
        WXSDKEngine.reload();
        Context context = WXEnvironment.getApplication();
        if (context != null) {
            context.sendBroadcast(new Intent()
                    .setAction(IWXDebugProxy.ACTION_DEBUG_INSTANCE_REFRESH)
                    .putExtra("params", null == params ? "" : params.toString())
            );
        }
    }

其实应该进这里

@ChromeDevtoolsMethod
    public void refresh(JsonRpcPeer peer, JSONObject params) {
        WXLogUtils.e("WxDebug-new >>>> refresh=" + params);
        Context context = WXEnvironment.getApplication();
        if (context != null) {
            context.sendBroadcast(new Intent()
                    .setAction(IWXDebugProxy.ACTION_DEBUG_INSTANCE_REFRESH)
                    .putExtra("params", null == params ? "" : params.toString())
            );
        }
    }

@mario-huang
Copy link

问题解决了,是weex-debug的锅。

@Ray-daydayup
Copy link

怎么解决

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants