使用插件缓存优化创建 VLC 组件的速度 #392
Replies: 5 comments 1 reply
-
那能不能在我电脑上建好缓存了带着缓存发布 |
Beta Was this translation helpful? Give feedback.
-
windows 可以 |
Beta Was this translation helpful? Give feedback.
-
在windows VLC 的安装目录有一个 vlc-cache-gen.exe,执行 createDistributable 之前用 vlc-cache-gen.exe 生成缓存。这是我的项目里的脚本:
val createVlcCacheDistributable by tasks.registering{
group = "compose desktop"
description = "Run vlc-cache-gen to generate VLC Plugins cache"
val createDistributable = tasks.named<org.jetbrains.compose.desktop.application.tasks.AbstractJPackageTask>("createDistributable")
dependsOn(createDistributable)
doLast{
println("Running custom task to generate VLC Plugins cache")
val cacheGen = project.layout.projectDirectory.dir("build/compose/binaries/main/app/幕境/app/resources/VLC/vlc-cache-gen.exe").getAsFile().absolutePath
val plugins = project.layout.projectDirectory.dir("build/compose/binaries/main/app/幕境/app/resources/VLC/plugins").getAsFile().absolutePath
val command = listOf(cacheGen, plugins)
try {
val process = ProcessBuilder(command).start()
process.waitFor()
} catch (e: Exception) {
println("Error running vlc-cache-gen: ${e.message}")
}
}
} |
Beta Was this translation helpful? Give feedback.
-
macOS 可能要修改VLC源码把插件缓存检查禁用。相关 Issue:JetBrains/compose-multiplatform#1089 (comment) |
Beta Was this translation helpful? Give feedback.
-
把 vlc-cache-gen.exe 添加到 afterEvaluate {
// 如果是 windows 系统,需要使用 vlc-cache-gen 生成 VLC 插件缓存
if (isWindows) {
tasks.named("createReleaseDistributable") {
doLast {
println("generate VLC Plugins cache")
val cacheGen = project.layout.projectDirectory.dir("build/compose/binaries/main-release/app/Ani/app/resources/lib/vlc-cache-gen.exe").asFile.absolutePath
val plugins = project.layout.projectDirectory.dir("build/compose/binaries/main-release/app/Ani/app/resources/lib/plugins").asFile.absolutePath
val command = listOf(cacheGen, plugins)
try {
val process = ProcessBuilder(command).start()
process.waitFor()
} catch (e: Exception) {
logger.error("Error running vlc-cache-gen: ${e.message}")
}
}
}
}
} 就可以在执行 在我的那个项目,最后把生成插件缓存延迟到了用户安装软件到安装目录之后才执行的。 |
Beta Was this translation helpful? Give feedback.
-
重建插件缓存,可以消除日志里的
stale plugins cache: modified
打包的时候把
plugins/plugins.dat
删除,然后启动的时候再重建,第一次创建 VLC 组件的时候可能会慢一点,在我的 Windows 上第一次创建 VLC 在 1秒左右,后面再创建 VLC 只需要 0.5 秒
windows 版,如果用户把软件安装在
C:\Program Files
VLC 没有权限生成 plugins.dat,要用管理员权限才能生成,所以可以先运行一次软件,生成 plugins.dat, 然后压缩安装包。Beta Was this translation helpful? Give feedback.
All reactions