- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我在 Android WebView 上玩得很开心。
我用它来显示登录屏幕,然后在响应时拦截授权代码。应该很简单...
如果我只覆盖 shouldOverrideUrlLoading 但如果我覆盖(就像 Android Studio 自动完成的那样),我的 WebView 加载和显示绝对正常:
override fun shouldInterceptRequest(
view: WebView?,
request: WebResourceRequest?
): WebResourceResponse {
return super.shouldInterceptRequest(view, request)
}
如果没有其他更改,它会在运行时立即崩溃并发生 native 崩溃
A/chromium: [FATAL:jni_android.cc(259)]
其次是
A/libc: Fatal signal 6 (SIGABRT), code -6 (SI_TKILL) in tid 16220 (TaskSchedulerFo), pid 16175 (eports.internal)
奇怪的是,如果我使响应可为空,WebView 将再次工作。但是,将任何其他内容添加到 shouldInterceptRequest 方法中都会使其因相同的错误而失败。
所以这是可行的:
override fun shouldInterceptRequest(
view: WebView?,
request: WebResourceRequest?
): WebResourceResponse? {
return super.shouldInterceptRequest(view, request)
}
但这会因上述崩溃而崩溃:
override fun shouldInterceptRequest(
view: WebView?,
request: WebResourceRequest?
): WebResourceResponse? {
val url = view?.url
return super.shouldInterceptRequest(view, request)
}
这似乎是一个非常奇怪的问题,我不明白为什么添加一个 val 赋值会有任何不同。
我一直在研究错误,建议补充
webView.destroy()
在 Activity/fragment onDestroy/onDestroyView 中,不幸的是,这没有帮助。
行为在设备和模拟器上以及在 Android sdk 22 和 28 上是相同的。
有没有人见过这样的事情?我觉得我可能遗漏了一些明显的东西。
如果它对任何人都有用,我也生成了 Breakpad Microdump,它太大而无法在这个问题中发布。但如果它或它的一个子集可能有助于诊断,请告诉我!
最佳答案
我在我的案例中发现了这个问题,所以我想我会把它发布在这里以供处于类似位置的其他人使用。
native 崩溃是由 WebView 中运行的 Javascript 引起的。
WebView 在后台线程中运行 JavaScript,因此任何接触 UI 线程的东西都会导致它在 native 级别上失败。给出上面非常无用的崩溃。
val 分配导致崩溃的原因不是 val 的分配,而是 if view?.url 的调用,它在 UIThread 上。
解决方案?
Kotlin :
webView?.post{
// Do your UI work here.
}
Java:
webView.post(new Runnable(){
public void run() {
// Do your UI work here.
}
})
并且不要在覆盖的方法中以其他方式触及 UIThread!
关于Android WebView 即时崩溃与 shouldInterceptRequest 覆盖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51358223/
我已经四处寻找我的问题的解决方案,但它们似乎都涉及看似复杂的方法,如数据透视表、交叉表等。似乎必须有一个更简单的解决方案来解决那些没有解决的问题在我看来是一个特别复杂的问题。我正在使用 MS SQL
我在共享服务器上安装了 MySQL,并且可以通过 phpMyAdmin 进行访问。我想将该数据库连续实时克隆到云 mySQL 数据库(我们专门为此数据库创建了一个支持 Nginx 的 MySQL 服务
我目前正在围绕一个相当复杂的数据模型编写一个 Django 应用程序。对于许多用例,我需要构建相似但略有不同的模板(包括 graphviz 等)。 现在我想知道是否有一种方法可以遵循 DRY 并“即时
我选择了图片并在提交表单之前进行了预览。但是我想在选择图像并预览并提交文件后即时编辑文件。 js代码: var img = null; var canvas1 = document.g
目前,我们的网站存储 2/3 的固定图像尺寸。这些在上传时生成并通过我们的 CDN 分发。然而,我们需要实现更灵活的解决方案,我们正在开发需要多种不同尺寸的移动和平板电脑应用程序。我们建议的解决方案是
在 Google Wave 的介绍视频中,他们谈到了网络应用程序中的聊天问题。在许多 Web 应用程序中,您会看到如下消息: is typing.. (消息提交前) Google 想出了一个想法“在键
这个问题在这里已经有了答案: Formatting a number with leading zeros in PHP [duplicate] (11 个回答) 关闭3年前. PHP - 是否有一种
如何在VBA的“即时”窗口中打印二维数组?是否存在执行此操作的通用方法?一种在“即时”窗口中为每行绘制一排数组的方法可以解决此问题,因为唯一要做的就是为数组的每一行循环此代码。 最佳答案 我做了一个简
与非 JIT 编译器相比,JIT 编译器具体做什么?谁能给出一个简洁易懂的描述? 最佳答案 JIT 编译器在程序启动后运行,并将代码(通常是字节码或某种 VM 指令)动态(或称为即时)编译为通常更快的
我已经在我的 Windows 2003 服务器上安装了 VisualSVN,并将其配置为提供匿名读取访问。据我了解,VisualSVN 仅使用 apache 和下面的官方 SVN 存储库服务器。 现在
我正在开发一个使用 Twig 的 PHP 应用程序(但这并不重要)作为 View 层。这个 View 层有一个自定义扩展,允许我注册远程样式和脚本 Assets 以及样式和脚本内联 block 。系统
如今在许多网页上,您会经常看到带有指向目标的箭头的即时工具提示,类似于: https://www.w3schools.com/css/tryit.asp?filename=trycss_tooltip
我正在用 C++ 编写并在 Windows 中使用 OpenGL。 我创建了一个立方体,我希望它通过按“4”或“6”小键盘键围绕 y 轴旋转(使用 glRotate3f(),而不是 gluLookat
与非 JIT 编译器相比,JIT 编译器具体做什么?谁能给出一个简洁易懂的描述? 最佳答案 JIT 编译器在程序启动后运行,并将代码(通常是字节码或某种 VM 指令)动态(或称为即时)编译为通常更快的
这个问题在这里已经有了答案: 关闭 10 年前。
与非 JIT 编译器相比,JIT 编译器具体做什么?谁能给个简洁易懂的描述? 最佳答案 JIT 编译器在程序启动后运行,并将代码(通常是字节码或某种 VM 指令)即时(或所谓的即时)编译成通常速度更快
与非 JIT 编译器相比,JIT 编译器具体做什么?谁能给个简洁易懂的描述? 最佳答案 JIT 编译器在程序启动后运行,并将代码(通常是字节码或某种 VM 指令)即时(或所谓的即时)编译成通常速度更快
我希望能够即时将音频文件转换为 MP3 以供用户浏览器使用。我正在使用的软件是:ubuntu 系统上的 Apache、PHP 和 FFMPEG。这是我到目前为止的代码: 使用此代码,仅转换音频的前几
我正在使用 IntervalObservable 连续调用我的应用程序的服务器端。我可以订阅和取消订阅 Oberservable,一切正常,但有一个异常(exception): 对服务器的第一次调用被
从服务器上的文件夹压缩(比如 2 个文件)并强制下载的最简单方法是什么?不将“zip”保存到服务器。 $zip = new ZipArchive(); //the string "fil
我是一名优秀的程序员,十分优秀!