Tencent / VasSonic

VasSonic is a lightweight and high-performance Hybrid framework developed by tencent VAS team, which is intended to speed up the first screen of websites working on Android and iOS platform.
Other
11.8k stars 1.61k forks source link

3.1.0版本调用sonicSession.destroy()报错 #316

Open 1079107009 opened 5 years ago

1079107009 commented 5 years ago

Activity销毁时调用

@Override
protected void onDestroy() {
    if (null != mSonicSession) {
        mSonicSession.destroy();
        mSonicSession = null;
    }
    super.onDestroy();
}

打印日志如下: 05-14 13:18:24.556 12741-12741/me.suncloud.marrymemo D/SonicSdk_SonicServer: session(84693) server disconnect error:null. 05-14 13:18:24.556 12741-12741/me.suncloud.marrymemo D/SonicSdk_SonicEngine: onSessionStateChange:session(84693) from state 2 -> 3 05-14 13:18:24.556 12741-12741/me.suncloud.marrymemo D/SonicSdk_SonicSession: session(84693) final destroy, force=false.

具体原因 server.disconnect();

public void disconnect() {
    try {
        BufferedInputStream bufferedInputStream = connectionImpl.getResponseStream();
        if (bufferedInputStream != null) {
            bufferedInputStream.close();
        }
    } catch (Throwable e) {
        SonicUtils.log(TAG, Log.ERROR, "session(" + session.sId + ") server disconnect error:" + e.getMessage() + ".");
    }
    connectionImpl.disconnect();
}

bufferedInputStream.close();android.os.NetworkOnMainThreadException

vasdeveloper commented 5 years ago

感谢反馈,我们会在近期修复相关bug