gallery/vendor/i-slint-renderer-skia/vulkan_handle.rs
Greg Pomerantz 93b27d724b Root-cause and fix the Mali scroll jank; strip jank-hunt instrumentation
The 19-26 ms mid-scroll stalls (Mali-only, fixed content offsets) were
the Skia renderer's final synchronous GrDirectContext::flush() blocking
the UI thread on Mali driver back-pressure — proven by per-stage
timestamps in the vendored renderer (stall frames: flush 19-24 ms,
walk 1-3 ms, 1 binding re-eval, image imports 0.1 ms each).

- vendor/i-slint-renderer-skia (pinned 1.18.1, [patch.crates-io]):
  remove that one flush. Redundant on the wgpu backend: the surface
  already calls flush_and_submit before queue.present, same Vulkan
  queue, in-order. Phone: 0 stalls across 4 runs (max 3.6-7.4 ms vs
  the 8.3 ms budget), display verified clean.
- docs/BUGS/slint-skia-final-flush-jank.md: full evidence, prior art
  (slint-ui/slint#12030 closest), open question for a future
  upstream filing (not filed yet).
- Profiling also retired the O(n)-walk theory: Slint 1.18 prunes the
  item walk to ~133-152 items; the windowed Flickable built on that
  theory was already reverted (ListView is smooth with the fix).
- Strip all jank-hunt instrumentation: FR/SCR/TICK/APLYD/STG logging,
  stg markers, .gallery_* file knobs, jsamp thread sampler,
  DbgScroll programmatic scroll, nblog perf-file mirroring.
  Also fixes the 'launches into unstoppable fast scroll' bug: a
  leftover .gallery_cmd was re-read on every launch (file never
  deleted) and overrode user swipes — the hook is gone.
- Keep: nblog (logd backpressure is real), zero-dimension decode
  guards, keep-alive (default-off).
- HANDOFF: replace stale windowed-Flickable section with the actual
  root cause/fix; 15 unit tests pass.

Verified on phone (aarch64, 8580 photos) and emulator (x86_64).
2026-10-28 18:23:50 -04:00

31 lines
1.3 KiB
Rust

// Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
// cSpell: ignore dispatchable
//! Raw values of the Vulkan handles wgpu-hal hands out.
//!
//! wgpu-hal exposes its Vulkan objects as `ash::vk` handle types without re-exporting `ash`,
//! and Skia's `vk` API takes the raw values.
//! Every `ash::vk` handle is a `#[repr(transparent)]` wrapper mirroring the C type:
//! a pointer for dispatchable handles (`VkInstance`, `VkQueue`, ...)
//! and a `u64` for non-dispatchable ones (`VkImage`, ...).
//! Reading the wrapper is what `ash::vk::Handle::as_raw` does, minus the dependency.
/// Returns the raw value of a dispatchable handle.
///
/// # Safety
/// `handle` must be one of `ash::vk`'s dispatchable handle types.
pub unsafe fn dispatchable<H: Copy>(handle: H) -> u64 {
const { assert!(size_of::<H>() == size_of::<*mut u8>()) };
unsafe { core::mem::transmute_copy::<H, *mut u8>(&handle) as u64 }
}
/// Returns the raw value of a non-dispatchable handle.
///
/// # Safety
/// `handle` must be one of `ash::vk`'s non-dispatchable handle types.
pub unsafe fn non_dispatchable<H: Copy>(handle: H) -> u64 {
const { assert!(size_of::<H>() == size_of::<u64>()) };
unsafe { core::mem::transmute_copy::<H, u64>(&handle) }
}