6.7.0 - Alpha14 - 修复脚本退出时可能的浮动窗口残留问题
This commit is contained in:
@@ -74,6 +74,7 @@
|
||||
"ocr.detect 方法获得的结果可能与 ocr.mode 不匹配的问题 _[`issue #468`](http://issues.autojs6.com/468)_",
|
||||
"auto.registerEvent 注册的无障碍服务事件会被其他脚本误清理的问题 _[`issue #466`](http://issues.autojs6.com/466)_ _[`issue #343`](http://issues.autojs6.com/343#issuecomment-3263953918)_",
|
||||
"Android 10 UiObject#child 方法可能出现 ArrayIndexOutOfBoundsException 异常的问题 _[`issue #416`](http://issues.autojs6.com/416)_",
|
||||
"脚本创建大量浮动窗口后, 脚本退出时可能出现窗口残留的问题",
|
||||
"运行项目时 project.json 配置参数可能无法正常解析的问题",
|
||||
"项目打包时 project.json 的 excludedDirs 配置参数将导致配置文件解析失败的问题 _[`issue #428`](http://issues.autojs6.com/428)_",
|
||||
"Android 7.x 可能无法正常使用打包功能的问题",
|
||||
|
||||
@@ -26,11 +26,13 @@ import org.autojs.autojs.util.RhinoUtils.newBaseFunction
|
||||
import org.autojs.autojs.util.ViewUtils.setViewMeasure
|
||||
import org.autojs.autojs6.R
|
||||
import java.util.concurrent.CopyOnWriteArraySet
|
||||
import java.util.concurrent.CountDownLatch
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
/**
|
||||
* Created by Stardust on Dec 5, 2017.
|
||||
* Modified by SuperMonster003 as of Mar 27, 2022.
|
||||
* Transformed by SuperMonster003 on Mar 27, 2022.
|
||||
* Modified by SuperMonster003 as of Jan 16, 2026.
|
||||
*/
|
||||
class Floaty(private val uiHandler: UiHandler, private val scriptRuntime: ScriptRuntime) {
|
||||
|
||||
@@ -89,10 +91,45 @@ class Floaty(private val uiHandler: UiHandler, private val scriptRuntime: Script
|
||||
|
||||
@Synchronized
|
||||
fun closeAll() {
|
||||
mWindows.apply {
|
||||
forEach { it.close(false) }
|
||||
clear()
|
||||
|
||||
// Close windows synchronously on UI thread.
|
||||
// Reason:
|
||||
// - close(false) is usually posted to UI thread via UiHandler.
|
||||
// - Under heavy start/stop stress, UI queue may be congested.
|
||||
// - If we clear mWindows before actual close runs, leaked windows may remain and block touch.
|
||||
//
|
||||
// zh-CN:
|
||||
//
|
||||
// 在 UI 线程同步关闭窗口.
|
||||
// 原因:
|
||||
// - close(false) 通常会通过 UiHandler 投递到 UI 线程异步执行.
|
||||
// - 在频繁启动/停止脚本的压力场景下, UI 队列可能严重拥堵.
|
||||
// - 如果在实际 close 执行前就清空 mWindows, 可能出现窗口残留并拦截触摸.
|
||||
val snapshot = mWindows.toList()
|
||||
|
||||
// Fast path: already on UI thread.
|
||||
// zh-CN: 快速路径: 已处于 UI 线程.
|
||||
if (isUiThread()) {
|
||||
snapshot.forEach { runCatching { it.close(false) } }
|
||||
mWindows.clear()
|
||||
return
|
||||
}
|
||||
|
||||
// Slow path: post to UI thread and wait with timeout.
|
||||
// zh-CN: 慢路径: 投递到 UI 线程并等待, 同时提供超时保护.
|
||||
val latch = CountDownLatch(1)
|
||||
uiHandler.post {
|
||||
try {
|
||||
snapshot.forEach { runCatching { it.close(false) } }
|
||||
mWindows.clear()
|
||||
} finally {
|
||||
latch.countDown()
|
||||
}
|
||||
}
|
||||
|
||||
// Wait a little to ensure removal is performed before runtime fully exits.
|
||||
// zh-CN: 等待一小段时间, 确保在运行时完全退出前窗口已被移除.
|
||||
runCatching { latch.await(1500, TimeUnit.MILLISECONDS) }
|
||||
}
|
||||
|
||||
@ScriptInterface
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#Fri Jan 16 17:47:33 CST 2026
|
||||
BUILD_TIME=1768556853657
|
||||
#Fri Jan 16 20:18:26 CST 2026
|
||||
BUILD_TIME=1768565906722
|
||||
COMPILE_SDK_VERSION=36
|
||||
IMAGE_QUANT_CMAKE_VERSION=3.22.1
|
||||
IMAGE_QUANT_NDK_VERSION=26.1.10909125
|
||||
@@ -27,6 +27,6 @@ RAPID_OCR_OPENCV_MOBILE_LABEL_VERSION=13
|
||||
RAPID_OCR_OPENCV_MOBILE_VERSION=4.5.3
|
||||
TARGET_SDK_VERSION=36
|
||||
TARGET_SDK_VERSION_INRT=29
|
||||
VERSION_BUILD=3620
|
||||
VERSION_BUILD=3622
|
||||
VERSION_NAME=6.7.0 Alpha14
|
||||
VSCODE_EXT_REQUIRED_VERSION=1.0.13
|
||||
|
||||
Reference in New Issue
Block a user