diff options
author | bptato <nincsnevem662@gmail.com> | 2024-07-21 00:37:17 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-07-21 00:41:26 +0200 |
commit | 1369135f9719ebe7a58c75fd73ecbfec92ef7e24 (patch) | |
tree | af9ee62f2138651618d206853bec4fe49dfd6e14 | |
parent | f60f8010604c227d13e1d953f1565d4d54174416 (diff) | |
download | chawan-1369135f9719ebe7a58c75fd73ecbfec92ef7e24.tar.gz |
dom: fix race condition in image loading
We were not setting the invalid flag on bitmap load, so any incremental reshape could interfere with displaying images that got loaded after the reshape.
-rw-r--r-- | src/html/dom.nim | 7 | ||||
-rw-r--r-- | todo | 2 |
2 files changed, 4 insertions, 5 deletions
diff --git a/src/html/dom.nim b/src/html/dom.nim index 123296f5..2cee89ac 100644 --- a/src/html/dom.nim +++ b/src/html/dom.nim @@ -3023,11 +3023,11 @@ proc loadResource(window: Window; image: HTMLImageElement) = let p = window.loader.fetch(newRequest(url)).then( proc(res: JSResult[Response]): EmptyPromise = if res.isNone: - return + return newResolvedPromise() let response = res.get let contentType = response.getContentType("image/x-unknown") if contentType.until('/') != "image": - return + return newResolvedPromise() let cacheId = window.loader.addCacheFile(response.outputId, window.loader.clientPid) let request = newRequest( @@ -3053,7 +3053,7 @@ proc loadResource(window: Window; image: HTMLImageElement) = break cachedURL.loading = false cachedURL.expiry = expiry - return r.then(proc(res: JSResult[Response]): EmptyPromise = + return r.then(proc(res: JSResult[Response]) = if res.isNone: return let response = res.get @@ -3082,6 +3082,7 @@ proc loadResource(window: Window; image: HTMLImageElement) = cachedURL.bmp = bmp for share in cachedURL.shared: share.bitmap = bmp + image.invalid = true ) ) window.loadingResourcePromises.add(p) diff --git a/todo b/todo index 9c2d3de7..1c924ee4 100644 --- a/todo +++ b/todo @@ -73,8 +73,6 @@ layout engine: images: - more efficient sixel display (store encoded images) - proper sixel color register allocation, dithering -- fix race condition where images decoded after buffer load won't display until - reshape - incremental decoding, interlaced images, animation man: - add a DOM -> man page converter so that we do not depend on pandoc |