Native iCloud apps for Windows and Linux, built in Rust. Notes, Reminders, Calendar, Contacts, Drive and Photos, offline and in sync with your iPhone.
Rust apple-notesapple-reminderscloudkitcrdtdesktop-appicloudicloud-calendaricloud-driveicloud-notesicloud-photosiphonelinuxlinux-desktoplocal-firstoffline-firstprivacyrusttauritauri-appwindows
Photos: full quality from the first frame; no tearing between photos; steady drawing on Wayland
Yashwanth Kamireddibfbe4ec65395
diff --git a/.uiverify/photos-quality.mjs b/.uiverify/photos-quality.mjsnew file mode 100644index 0000000..4ee66c7--- /dev/null+++ b/.uiverify/photos-quality.mjs@@ -0,0 +1,27 @@+// A photo at full quality from the first frame: once its whole picture is decoded — as it is+// fetched before it opens, and for the photos either side while one shows — the viewer shows+// that alone, never a smaller copy first; stepping lands on a whole picture too.+import { engine } from "./engine.mjs";+import { SERVICES, installStub, openScreen } from "./stub.mjs";+const b = await engine.launch();+const ctx = await b.newContext({ viewport: { width: 1280, height: 800 } });+await ctx.addInitScript(installStub, { screen: "library", services: SERVICES, twoFactor: null });+// Pictures here cannot be fetched; decoding is made to succeed, as it does in the app.+await ctx.addInitScript(() => { HTMLImageElement.prototype.decode = function () { return Promise.resolve(); }; });+const page = await ctx.newPage();+page.on("pageerror", (e) => { console.log(`FAIL page error: ${e.message}`); process.exitCode = 1; });+await page.goto("http://localhost:4173", { waitUntil: "networkidle" });+await openScreen(page, "Photos");+await page.waitForTimeout(400);+let failures = 0;+const ok = (p, m) => { console.log(`${p ? "PASS" : "FAIL"} ${m}`); if (!p) failures++; };+const shown = () => page.locator(".px-stage .px-shown").getAttribute("src");++await page.locator(".px-tile").nth(0).dblclick();+await page.waitForTimeout(80);+ok(/full/.test((await shown()) ?? "") && (await page.locator(".px-sharp").count()) === 0, `it opens on the whole picture, alone ${await shown()}`);+await page.keyboard.press("ArrowRight");+await page.waitForTimeout(30);+ok(/p2.*full|full.*p2/.test(decodeURIComponent((await shown()) ?? "")), `a step lands on the next whole picture at once ${await shown()}`);+await b.close();+process.exitCode = failures ? 1 : (process.exitCode ?? 0);diff --git a/.uiverify/photos-show.mjs b/.uiverify/photos-show.mjsindex a1a644d..af9a334 100644--- a/.uiverify/photos-show.mjs+++ b/.uiverify/photos-show.mjs@@ -19,6 +19,11 @@ await page.locator(".px-tile").nth(1).click({ button: "right" });await page.locator(".row-menu").getByText("Start Slideshow").click();await page.waitForTimeout(200);ok((await page.locator(".px-show").count()) === 1 && (await count()) === "2 of 5", `it begins at the photo it was started from "${await count()}"`);+const fills = await page.locator(".px-show").evaluate((el) => {+ const r = el.getBoundingClientRect();+ return r.left === 0 && r.top === 0 && Math.round(r.width) === innerWidth && Math.round(r.height) === innerHeight;+});+ok(fills, "it fills the whole window, not a box inside the screen");await page.waitForTimeout(4400);ok((await count()) === "3 of 5", `and goes on by itself "${await count()}"`);await page.keyboard.press(" ");diff --git a/.uiverify/photos.mjs b/.uiverify/photos.mjsindex ef17a9e..c0c1bcf 100644--- a/.uiverify/photos.mjs+++ b/.uiverify/photos.mjs@@ -169,7 +169,7 @@ ok((await page.locator(".px-tile").count()) === 5, "and it is back in the librar// Zooming into a photo: double-click zooms to where was clicked, with the full picture// laid over; Escape zooms back out before it closes; Ctrl+wheel zooms; the grid's own zoom-// keys are not taken while a photo is open; the next photo slides in.+// keys are not taken while a photo is open; the arrows step at once.await page.locator(".px-tile").nth(1).dblclick();await page.waitForTimeout(600);const scaleOf = () => page.locator(".px-pan").evaluate((el) => new DOMMatrix(getComputedStyle(el).transform).a);@@ -195,13 +195,12 @@ ok((await scaleOf()) > 1.2 && (await page.evaluate(() => getComputedStyle(docume"Ctrl = zooms the photo, not the grid behind it");await page.keyboard.press("Control+0");await page.keyboard.press("ArrowLeft");-await page.waitForTimeout(30);-ok((await page.locator(".px-pan").evaluate((el) => el.getAnimations().length)) > 0, "the photo before slides in");-await page.waitForTimeout(400);+await page.waitForTimeout(60);+ok(/p1/.test((await page.locator(".px-shown").getAttribute("src")) ?? ""), "the left arrow goes to the photo before, at once");await page.keyboard.press("ArrowRight");await page.keyboard.press("ArrowRight");-await page.waitForTimeout(30);-ok((await page.locator(".px-video").evaluate((el) => el.getAnimations().length)) > 0, "a video slides in the same way");+await page.waitForTimeout(60);+ok((await page.locator(".px-video").count()) === 1, "and on to a video");await page.waitForTimeout(400);await page.keyboard.press("Escape");await page.waitForTimeout(650);diff --git a/check.sh b/check.shindex 9890ed3..8308a37 100755--- a/check.sh+++ b/check.sh@@ -71,6 +71,7 @@ step "place & keywords" node .uiverify/photos-info.mjsstep "download options" node .uiverify/photos-download.mjsstep "adjust date" node .uiverify/photos-date.mjsstep "photo search" node .uiverify/photos-search.mjs+step "full quality" node .uiverify/photos-quality.mjsstep "notes delete" node .uiverify/notes-delete.mjsstep "empty today" node .uiverify/reminders-empty.mjsstep "calendar keys" node .uiverify/calendar-keys.mjs@@ -125,6 +126,7 @@ step "webkit: place & keywords" env ENGINE=webkit node .uiverify/photos-info.mjsstep "webkit: downloads" env ENGINE=webkit node .uiverify/photos-download.mjsstep "webkit: adjust date" env ENGINE=webkit node .uiverify/photos-date.mjsstep "webkit: search" env ENGINE=webkit node .uiverify/photos-search.mjs+step "webkit: full quality" env ENGINE=webkit node .uiverify/photos-quality.mjsstep "webkit: delete" env ENGINE=webkit node .uiverify/notes-delete.mjsstep "webkit: row hover" env ENGINE=webkit node .uiverify/row-hover.mjsstep "webkit: fold" env ENGINE=webkit node .uiverify/sidebar-fold.mjsdiff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rsindex 83ab103..c20b913 100644--- a/src-tauri/src/main.rs+++ b/src-tauri/src/main.rs@@ -3461,6 +3461,23 @@ fn adopt_writer(library: &mut Library) {quince_icloud::topotext::set_writer(*id.as_bytes());}+/// WebKitGTK hands its frames to the compositor as DMA-BUFs; on Wayland that path tears and+/// flickers — whole-window flashes on a resize, on a menu, on a screen changing — which he saw+/// across the app. Turning it off (WebKitGTK's own switch, the one Tauri's Linux users are+/// pointed to) draws through shared memory instead, steadily. Only under Wayland, only when the+/// person has not set it themselves; `QUINCE_DMABUF=1` keeps DMA-BUF for anyone who wants it.+fn steady_drawing() {+ let wayland = std::env::var("XDG_SESSION_TYPE")+ .is_ok_and(|s| s.eq_ignore_ascii_case("wayland"))+ || std::env::var_os("WAYLAND_DISPLAY").is_some_and(|v| !v.is_empty());+ let chosen = std::env::var_os("WEBKIT_DISABLE_DMABUF_RENDERER").is_some()+ || std::env::var_os("QUINCE_DMABUF").is_some_and(|v| v == "1");+ if wayland && !chosen {+ // Before any thread starts: nothing else can be reading the environment yet.+ std::env::set_var("WEBKIT_DISABLE_DMABUF_RENDERER", "1");+ }+}+/// Whether this session runs under a tiling Wayland compositor, which manages windows itself.fn tiling_compositor() -> bool {let set = |k: &str| std::env::var_os(k).is_some_and(|v| !v.is_empty());@@ -3542,6 +3559,7 @@ fn build_tray(app: &tauri::App) -> tauri::Result<()> {}fn main() {+ steady_drawing();tauri::Builder::default()// One Quince at a time: opening it again brings back the one already running, which// may be sitting in the tray with its window closed.diff --git a/src/screens/PhotosView.tsx b/src/screens/PhotosView.tsxindex cf2e957..dc53688 100644--- a/src/screens/PhotosView.tsx+++ b/src/screens/PhotosView.tsx@@ -22,6 +22,7 @@ import { useSync } from "../lib/sync";import { Notice } from "../components/Notice";import { UploadPanel } from "./photos/UploadPanel";import { RowMenu, type MenuEntry } from "../components/RowMenu";+import { Portal } from "../components/Portal";import { Slideshow } from "./photos/Slideshow";import { DownloadOptions, type Want } from "./photos/DownloadOptions";import { AdjustDate } from "./photos/AdjustDate";@@ -154,6 +155,35 @@ function Filmstrip({ photos, at, onPick }: { photos: Photo[]; at: number; onPick);}+/**+ * Whole pictures already fetched and decoded, by photo. A photo in here opens and is stepped to+ * at full quality at once — never a blurry stand-in first. The bytes stay in the webview's+ * cache (and on disk); this is only which are known to be ready.+ */+const decodedFull = new Set<string>();+const warming = new Map<string, Promise<boolean>>();+function warm(id: string): Promise<boolean> {+ if (decodedFull.has(id)) return Promise.resolve(true);+ let ready = warming.get(id);+ if (!ready) {+ const img = new Image();+ img.decoding = "async";+ img.src = pictureSrc(id, "full");+ ready = img+ .decode()+ .then(+ () => {+ decodedFull.add(id);+ return true;+ },+ () => false,+ )+ .finally(() => warming.delete(id));+ warming.set(id, ready);+ }+ return ready;+}+/** What a tile can ask of the screen; one object, kept the same, so tiles need not redraw. */type Acts = {pick: (index: number, e: React.MouseEvent) => void;@@ -511,7 +541,6 @@ export function PhotosView() {height: Math.round(p.height * k),maxWidth: "none",maxHeight: "none",- backgroundImage: `url("${pictureSrc(p.id, "thumb")}")`,};};const still = () => typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;@@ -573,14 +602,11 @@ export function PhotosView() {// A finish that never comes (a hidden window stops the clock) must not leave it open.closingRun.current = { anims, timer: window.setTimeout(done, 600) };}, [open, photos]);- // Which way the last step went, so the next photo slides in from that side.- const stepped = useRef(0);const step = useCallback((by: number) =>setOpen((at) => {if (at === null || !photos) return at;const to = Math.max(0, Math.min(photos.length - 1, at + by));- if (to !== at) stepped.current = by;return to;}),[photos],@@ -642,17 +668,16 @@ export function PhotosView() {return () => el.removeEventListener("wheel", wheel);});const dragging = useRef<{ x: number; y: number; lx: number; ly: number } | null>(null);- // The next photo slides in from the side the step went to.- useLayoutEffect(() => {- const by = stepped.current;- stepped.current = 0;- const el = stage.current?.querySelector<HTMLElement>(".px-pan, .px-video");- if (!by || !el || still() || typeof el.animate !== "function") return;- el.animate(- [{ transform: `translateX(${by * 56}px)`, opacity: 0.2 }, { transform: "none", opacity: 1 }],- { duration: 300, easing: spring() },- );- }, [shown?.id]); // eslint-disable-line react-hooks/exhaustive-deps+ // The photos either side are fetched and decoded while this one shows, so a step lands on+ // a whole picture at once. (No slide between them: moving a picture as it changes is what+ // tore in WebKitGTK.)+ useEffect(() => {+ if (open === null || !photos) return;+ for (const by of [1, -1, 2, -2]) {+ const p = photos[open + by];+ if (p && p.kind !== "video") void warm(p.id);+ }+ }, [open, photos]);// The viewer's keys: arrows to go through, Escape to close, I for the details.useEffect(() => {@@ -844,9 +869,12 @@ export function PhotosView() {const selected = useMemo(() => (photos ?? []).filter((p) => chosen.has(p.id)), [photos, chosen]);- const openAt = (index: number) => {+ const openAt = async (index: number) => {const p = photos?.[index];if (!p) return;+ // Open at full quality: the whole picture decoded first — from disk, a moment — but never+ // waited on for longer than a blink; past that it opens and the whole picture follows.+ if (p.kind !== "video") await Promise.race([warm(p.id), new Promise((r) => window.setTimeout(r, 400))]);stopClosing();const tile = document.querySelector<HTMLElement>(`.px-tile[data-id="${CSS.escape(p.id)}"]`);origin.current = tile?.getBoundingClientRect() ?? null;@@ -1884,8 +1912,13 @@ export function PhotosView() {onPointerUp={() => (dragging.current = null)}onPointerCancel={() => (dragging.current = null)}>- <img key={shown.id} className="px-shown" src={pictureSrc(shown.id, "medium")} alt={shown.filename ?? ""} decoding="async" draggable={false} style={fitted(shown)} />- {sharp === shown.id && (+ {decodedFull.has(shown.id) ? (+ // Already whole and decoded: drawn at once, at full quality, alone.+ <img key={`${shown.id}-whole`} className="px-shown" src={pictureSrc(shown.id, "full")} alt={shown.filename ?? ""} decoding="sync" draggable={false} style={fitted(shown)} />+ ) : (+ <img key={shown.id} className="px-shown" src={pictureSrc(shown.id, "medium")} alt={shown.filename ?? ""} decoding="async" draggable={false} style={fitted(shown)} />+ )}+ {sharp === shown.id && !decodedFull.has(shown.id) && (<imgkey={`${shown.id}-full`}className="px-sharp"@@ -2048,9 +2081,23 @@ export function PhotosView() {</p>)}{menu && <RowMenu at={menu.at} entries={menu.entries} onClose={() => setMenu(null)} />}- {show && <Slideshow photos={show.list} start={show.start} onClose={() => setShow(null)} />}- {adjusting && <AdjustDate photo={adjusting} onSave={(t) => void redate(adjusting, t)} onClose={() => setAdjusting(null)} />}- {options && <DownloadOptions photos={options} onPick={(w) => void downloadAs(options, w)} onClose={() => setOptions(null)} />}+ {/* Drawn at the top of the page: inside the screen, whose content moves by a transform,+ "fixed" was fixed to the screen and a slideshow played inside a box, not the window. */}+ {show && (+ <Portal>+ <Slideshow photos={show.list} start={show.start} onClose={() => setShow(null)} />+ </Portal>+ )}+ {adjusting && (+ <Portal>+ <AdjustDate photo={adjusting} onSave={(t) => void redate(adjusting, t)} onClose={() => setAdjusting(null)} />+ </Portal>+ )}+ {options && (+ <Portal>+ <DownloadOptions photos={options} onPick={(w) => void downloadAs(options, w)} onClose={() => setOptions(null)} />+ </Portal>+ )}<UploadPanel uploads={[...uploads.values()]} onDismiss={dismissUploads} cancel={api.photosUploadCancel} /></div>);