perf(gallery): v3.26.131 缩略图改 objectURL(修宫格加载慢)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 39s
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 39s
This commit is contained in:
1 parent
3e0fb3bdf8
commit
e59011b591
8 files changed
+51
-7
No files matched your search
@@ -16,6 +16,15 @@
|
||||
> 3. 核验正式地址版本 → 之后才移动 `stable` / `stable-verified-<日期>` 标签、更新本 CHANGELOG、写 GitHub Release(`gh release create`)。
|
||||
> 测试发现问题 → 改 → 再 `deploy:test`,正式环境不受影响。回滚点 `git reset --hard stable`。
|
||||
|
||||
## v3.26.131(2026-11-30)图库缩略图改 objectURL(修「能加载但很慢」)
|
||||
|
||||
宫格每张缩略图原来都走 `galleryThumb()`:读盘 → base64 → 返回 dataURL。
|
||||
164 张 = 164 次 IPC + 每次 20~40KB 字符串,开一次面板就是 3~6MB 字符串搬运。
|
||||
|
||||
- 新增 `galleryThumbUrl()`:读一次盘、建一个 objectURL,LRU 500 条;重复打开零成本。
|
||||
- `thumbFor` 优先走 objectURL,拿不到才退回 dataURL。
|
||||
- 缺缩略图的条目 settle 等待 3s → 1.6s,别再拖住整格。
|
||||
|
||||
## v3.26.130(2026-11-30)插件页显示已安装版本(原来显示的是市场版本)
|
||||
|
||||
129 的「插件源」读数证明:加载器读到的就是新版(gallery@1.9.8 / album@1.2.4 / promptlib@1.14.10),
|
||||
|
||||
@@ -7771,7 +7771,7 @@ const tbCenterSeed = (type, refs) => {
|
||||
list: (o) => window.IWBPluginGallery.query(outputs, o),
|
||||
// v3.26.61:缩略图取源顺序(清单 data → images/thumbs → 本地原图 → 远程)在 gallery-sync 里,
|
||||
// 原因是「生图后图库不显示」有一半出在这里 —— 新图 data 还没 hydrate 就只剩远程 url 可退。
|
||||
thumb: (name) => (wGallerySync ? wGallerySync.thumbFor(name, { outputs, displayThumbOf: wDisplayThumbOf, galleryThumb: (h) => { const F = (typeof window !== 'undefined') ? window.IWBStorageFile : null; return (F && typeof F.galleryThumb === 'function') ? F.galleryThumb(h) : Promise.resolve('') } }) : ''),
|
||||
thumb: (name) => (wGallerySync ? wGallerySync.thumbFor(name, { outputs, displayThumbOf: wDisplayThumbOf, galleryThumb: (h) => { const F = (typeof window !== 'undefined') ? window.IWBStorageFile : null; return (F && typeof F.galleryThumb === 'function') ? F.galleryThumb(h) : Promise.resolve('') }, galleryThumbUrl: (h) => { const F = (typeof window !== 'undefined') ? window.IWBStorageFile : null; return (F && typeof F.galleryThumbUrl === 'function') ? F.galleryThumbUrl(h) : Promise.resolve('') } }) : ''),
|
||||
preview: (name) => setPreview({ list: outputs.map((x) => ({ __gallery: true, name: x.name, origIdb: x.origIdb, idb: x.idb, url: x.url, thumb: x.data || null })), idx: Math.max(0, outputs.findIndex((x) => x.name === name)) }),
|
||||
download: async (names) => {
|
||||
const failed = []
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "image-workbench-web",
|
||||
"private": true,
|
||||
"version": "3.26.130",
|
||||
"version": "3.26.131",
|
||||
"description": "Browser-based node canvas image workbench",
|
||||
"scripts": {
|
||||
"build": "node scripts/build.js && node scripts/copy-plugins.js",
|
||||
|
||||
Generated
+1
-1
@@ -2014,7 +2014,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "image-workbench"
|
||||
version = "3.26.130"
|
||||
version = "3.26.131"
|
||||
dependencies = [
|
||||
"arboard",
|
||||
"base64 0.22.1",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "image-workbench"
|
||||
version = "3.26.130"
|
||||
version = "3.26.131"
|
||||
description = "无限画布 · 生图工作台桌面版"
|
||||
authors = ["malongan"]
|
||||
license = ""
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
|
||||
"productName": "image-workbench",
|
||||
"version": "3.26.130",
|
||||
"version": "3.26.131",
|
||||
"identifier": "com.malongan.imageworkbench",
|
||||
"build": {
|
||||
"frontendDist": "../dist",
|
||||
|
||||
+5
-1
@@ -186,7 +186,7 @@
|
||||
// 等缩略图就绪(最多 ~3s):宫格显示「加载中…」好过把 8MB base64 塞进 DOM
|
||||
const settle = async (src) => {
|
||||
if (!src) return ''
|
||||
for (let i = 0; i < 15; i++) {
|
||||
for (let i = 0; i < 8; i++) { // v3.26.131:3s → 1.6s,缺缩略图的卡别把宫格拖住
|
||||
const u = display(src)
|
||||
if (u && !HUGE_DATA(u)) return u
|
||||
await new Promise((r) => setTimeout(r, 200))
|
||||
@@ -198,6 +198,10 @@
|
||||
// 原因:displayThumbOf 会给每张图 mint 一个 objectURL 并写进宿主 displayThumbs(300),
|
||||
// 点开图库面板就是上百个 objectURL + 上百张 512 解码位图;关闭面板后这些 URL 仍被缓存持有,
|
||||
// 位图也就跟着留着。320 缩略图本身是 ~20KB 的 data URL,内核可随时丢弃,直接给 <img> 最省。
|
||||
// v3.26.131:优先要 **objectURL**(首帧可用、重复打开零成本);拿不到再退回 dataURL。
|
||||
if (f.thumbHash && typeof e.galleryThumbUrl === 'function') {
|
||||
try { const v = await e.galleryThumbUrl(f.thumbHash); if (v) return v } catch (err) { /* 继续 */ }
|
||||
}
|
||||
if (f.thumbHash && typeof e.galleryThumb === 'function') {
|
||||
try { const v = await e.galleryThumb(f.thumbHash); if (v && !HUGE_DATA(v)) return v } catch (err) { /* 继续本地副本 */ }
|
||||
}
|
||||
|
||||
+32
-1
@@ -1071,6 +1071,37 @@
|
||||
thumbMapCache = map
|
||||
return map
|
||||
}
|
||||
// v3.26.131:宫格缩略图改发 **objectURL**(同一张只读一次盘、只建一次 URL)。
|
||||
// 原来每张都 base64 成 dataURL(20~40KB 字符串),164 张 ⇒ 每次开面板 3~6MB 字符串 + 164 次 IPC,
|
||||
// 这就是「能加载但很慢」的来源。objectURL 首帧即用,重复打开直接命中。
|
||||
const galleryUrlCache = new Map()
|
||||
async function galleryThumbUrl(hash) {
|
||||
try {
|
||||
if (!enabled() || !dir || !hash) return ''
|
||||
const k = String(hash)
|
||||
const hit = galleryUrlCache.get(k)
|
||||
if (hit) {
|
||||
// 命中移到队尾(LRU)
|
||||
galleryUrlCache.delete(k); galleryUrlCache.set(k, hit)
|
||||
return hit
|
||||
}
|
||||
const map = await thumbFileMap()
|
||||
const name = map[k]
|
||||
if (!name) return ''
|
||||
const u8 = await fs().readFile(await join(dir, IMG_DIR, 'thumbs', name))
|
||||
if (!u8 || !u8.length) return ''
|
||||
const mime = sniffMime(u8) || (/\.png$/i.test(name) ? 'image/png' : 'image/jpeg')
|
||||
const url = URL.createObjectURL(new Blob([u8], { type: mime }))
|
||||
galleryUrlCache.set(k, url)
|
||||
while (galleryUrlCache.size > 500) {
|
||||
const oldK = galleryUrlCache.keys().next().value
|
||||
try { URL.revokeObjectURL(galleryUrlCache.get(oldK)) } catch (e) { /* ignore */ }
|
||||
galleryUrlCache.delete(oldK)
|
||||
}
|
||||
return url
|
||||
} catch (e) { return '' }
|
||||
}
|
||||
|
||||
async function galleryThumb(hash) {
|
||||
try {
|
||||
if (!enabled() || !dir || !hash) return ''
|
||||
@@ -1533,7 +1564,7 @@
|
||||
enabled, ready: init, flush,
|
||||
// 供其它模块把诊断写进 _boot.log(v3.26.109)
|
||||
logLine: (m) => blog(m),
|
||||
runtime, pickDir, switchTo, migrateTo, deleteImageBytes, deleteGalleryBytesFor, galleryAudit, gcImages, rotateTrash, galleryThumb, readDisplayThumb, readDisplayThumbUrl, makeDisplayThumb, makeDisplayThumbFromPath, resizeDataUrl, decodeStats, thumbStats, writeDisplayThumb, writeDisplayThumbBlob, pruneThumbs, cleanupLegacy, maintain,
|
||||
runtime, pickDir, switchTo, migrateTo, deleteImageBytes, deleteGalleryBytesFor, galleryAudit, gcImages, rotateTrash, galleryThumb, galleryThumbUrl, readDisplayThumb, readDisplayThumbUrl, makeDisplayThumb, makeDisplayThumbFromPath, resizeDataUrl, decodeStats, thumbStats, writeDisplayThumb, writeDisplayThumbBlob, pruneThumbs, cleanupLegacy, maintain,
|
||||
plugins: { manifest: pluginManifest, read: pluginRead, write: pluginWrite, remove: pluginRemove, dir: pluginDir, listLocal: pluginListLocal, listDirs: pluginListDirs, readFile: pluginReadFile, writeFile: pluginWriteFile, writeBinary: pluginWriteBinary, mkdir: pluginMkdir, removeDir: pluginRemoveDir, renameDir: pluginRenameDir, existsDir: pluginExistsDir },
|
||||
pluginData: { read: pluginDataRead, write: pluginDataWrite, remove: pluginDataRemove, list: pluginDataList },
|
||||
pluginFiles: { put: pluginFilePut, get: pluginFileGet, list: pluginFileList, remove: pluginFileRemove, stat: pluginFileStat, dir: pluginFilesDir, readBytes: pluginFileReadBytes, listAll: pluginFilesListAll },
|
||||
|
||||
Reference in new issue
Block a user