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

最新版本android.os.DeadObjectException #35

Open
zongleilei opened this issue May 8, 2017 · 6 comments
Open

最新版本android.os.DeadObjectException #35

zongleilei opened this issue May 8, 2017 · 6 comments
Labels

Comments

@zongleilei
Copy link

最新版本中在主进程启动service,子进程即使在退出前调用HermesEventBus.getDefault().destroy();然后杀死子进程(Process.killProcess(Process.myPid());)后,再启动子进程,主进程使用HermesEventBus post事件后仍然产生异常:android.os.DeadObjectException,调试发现是主进程持有已经dead的子进程service造成的,可在子进程退出前该怎么处理呢?

@zongleilei
Copy link
Author

HermesEventBus的实现发现有2个问题:

  1. 在子进程connect时用的是Service.class,而destory时的disconnect用的是HermesService0.class;
    这样子进程在退出时肯定无法从MainService中unregister自己的;
    2.即使将上述问题都改为Service.class,子进程仍然无法unregister自己,原因是子进程退出时并不会调用onHermesDisconnected回调;
    不知该怎么处理才对呢?

@zongleilei
Copy link
Author

我的处理是在HermesEventBus中添加unInit方法,退出前调用,手动从主进程中移除自己:
public void unInit() {
if (!mMainProcess) {
mState = STATE_DISCONNECTED;
if (mRemoteApis != null) {
mRemoteApis.action(new Action() {
@OverRide
public void call(IMainService o) {
o.unregister(Process.myPid());
}
});
}
}
}

@Xiaofei-it
Copy link
Owner

你这个问题我要查一下。你如果有好的处理办法,可以提pr。

@Xiaofei-it Xiaofei-it added the bug label May 8, 2017
@zongleilei
Copy link
Author

zongleilei commented May 8, 2017 via email

@tpnet
Copy link

tpnet commented Dec 20, 2017

@zongleilei 你好,这个问题怎么解决呢,我也是出现了DeadObjectException

@zongleilei
Copy link
Author

zongleilei commented Dec 22, 2017 via email

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

No branches or pull requests

3 participants