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

在插件的布局或代码中添加WebView会导致插件崩溃 #54

Closed
hsynlove opened this issue Jul 18, 2019 · 8 comments
Closed

在插件的布局或代码中添加WebView会导致插件崩溃 #54

hsynlove opened this issue Jul 18, 2019 · 8 comments

Comments

@hsynlove
Copy link

在插件的测试中对Activity生命周期测试的xml中添加WebView控件会导致插件崩溃且没有有效的错误信息。改动部分代码在本地测试项目在https://github.com/hsynlove/Shadow.git中。
另咨询插件App是独立可运行的,但是作为插件运行中发生的错误有些情况没有日志,请问如何追踪呢。

@shifujun
Copy link
Collaborator

感谢反馈。插件是在单独进程的,这可能是你没看到log的原因。我晚点查这个问题。

1 similar comment
@shifujun
Copy link
Collaborator

感谢反馈。插件是在单独进程的,这可能是你没看到log的原因。我晚点查这个问题。

@shifujun
Copy link
Collaborator

如果你测试使用的是Android 9.0或更高版本系统,应该是下面的原因。否则就是其他我复现不了的问题了。

日志看不到是因为Crash后进程立刻重启了,我们可以在启动插件进程后专门根据pid过滤Log,就能看到插件进程最后几行Log如下:

2019-07-18 19:45:46.882 7267-7267/com.tencent.shadow.sample.host:plugin W/ple.host:plugi: Accessing hidden method Landroid/view/textclassifier/logging/SmartSelectionEventTracker;-><init>(Landroid/content/Context;I)V (light greylist, reflection)
2019-07-18 19:45:46.884 7267-7267/com.tencent.shadow.sample.host:plugin W/System.err: StrictMode VmPolicy violation with POLICY_DEATH; shutting down.
2019-07-18 19:45:46.884 7267-7267/com.tencent.shadow.sample.host:plugin I/Process: Sending signal. PID: 7267 SIG: 9

所以可以看到,这是因为Sample默认打开了严格检查模式,而WebView的实现调用了灰名单方法。所以,应该是Android系统中自己还有一些实现没有避免使用私有API呢。可以去掉com.tencent.shadow.sample.host.HostApplication#detectNonSdkApiUsageOnAndroidP调用,来继续验证WebView的兼容性。

@shifujun
Copy link
Collaborator

我考虑咱们是不是这样改一下?

在宿主程序启动界面加上一个默认为关闭的滑动开关。仅当Android 9.0以上版本显式。开关控制是否调用com.tencent.shadow.sample.host.HostApplication#detectNonSdkApiUsageOnAndroidP方法。

虽然不复杂,但是能不能请你帮Shadow写一下这个功能呢?主要目的在于参与共同建设Shadow的代码。

@hsynlove
Copy link
Author

嗯 我也发现了如果开启严格模式会导致我手机报错,另外对AppCompat包中使用控件,在宿主的Application中设置AppCompat的theme就可以不报错了。

@hsynlove
Copy link
Author

非常感谢!我本地原项目的Shadow化已经基本完成,等测试稳定以后我再提交部分补充。

@shifujun
Copy link
Collaborator

另外的问题最好另外提个issue跟进。最好把代码也传上来。

@hsynlove
Copy link
Author

好的,我也是在原项目的改造过程中,逐步摸索、排错。如果发现不是因为我使用问题导致的错误我会提交issue并补充代码的。

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

2 participants