Skip to content

Commit

Permalink
🐛 [browser] 修复browser tabs关闭死锁
Browse files Browse the repository at this point in the history
  • Loading branch information
waterbang committed May 13, 2024
1 parent 32635f6 commit 65dc97a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,20 @@ sealed class BrowserPage(browserController: BrowserController) {
* 比方说,IOS与Desktop是混合视图,因此可以重写这个函数,让webview进行截图,然后在 placeholderNode 背后绘制截图内容
* Android 这是调用 view.invalidate() 从而实现onDraw的触发,从而能够被 captureController 所捕捉到这一帧发生的变化
*/
open fun onRequestCapture() {}
open fun onRequestCapture(): Boolean {
return true
}

@OptIn(ExperimentalCoroutinesApi::class)
fun captureViewInBackground() = synchronized(captureLock) {
captureJob ?: captureController.captureAsync().also { job ->
captureJob = job
onRequestCapture()


// 如果调用截图失败,释放相关资源
if (!onRequestCapture()) {
captureJob = null
}
job.invokeOnCompletion { error ->
if (error == null) {
thumbnail = job.getCompleted()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ class BrowserWebPage(val webView: IDWebView, browserController: BrowserControlle
}
}

override fun onRequestCapture() {
if (isDestroy) return
override fun onRequestCapture(): Boolean {
if (isDestroy) return false
requestCaptureInCompose()
return true
}

internal fun superUpdateUrl(url: String) {
Expand All @@ -75,6 +76,7 @@ class BrowserWebPage(val webView: IDWebView, browserController: BrowserControlle
}

private val searchEngine: SearchEngine? = null

// 根据url来搜索
fun loadUrl(url: String) {
// 判断 url 是否是 webUrl,如果是,直接loadUrl;如果不是,判断之前使用的搜索引擎将关键字替换了,进行搜索
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ internal suspend fun pureChannelToIpcEvent(
// 这里使用和生命周期一致的 order,以确保对面反能在数据消息接收完后再处理关闭信号
orderBy = IpcLifecycle.DEFAULT_ORDER,
)
channelIpc.debugIpc(debugTag) { "outChannelData=$ipcDataEvent" }
// channelIpc.debugIpc(debugTag) { "outChannelData=$ipcDataEvent" }
channelIpc.postMessage(ipcDataEvent)
}
/// 绑定 channel => ipc 的关闭
Expand Down

0 comments on commit 65dc97a

Please sign in to comment.