Repository navigation
Conversation
mikelxc
marked this pull request as ready for review
October 2, 2026 00:54
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Creating an ROI or enabling an overlay sends
ImageCanvasthroughpaintDoubleBuffered. Its offscreen image currently uses logicalsrcRect × magnificationdimensions and loses the destination graphics scale. This patch allocates a raster for the transformed image bounds, preserves the full destination transform (including fractional pixel phase) while painting it, and presents it at an integer device-pixel origin using the inverse transform. A cleared ARGB raster handles fractional-edge padding. It keeps double buffering and the existing 1× image creation path; it does not disable acceleration or alter image data.Evidence
This originated from a user report: native Apple Silicon Fiji is sharp until an ROI is created; removing it restores sharpness. Both portable and bundled ARM distributions reportedly reproduce, Intel/Rosetta reportedly avoids it, and forcing Metal off/OpenGL on reportedly did not help. A live native ARM64 Retina diagnostic now reproduces the same sharp → ROI detail loss → deselection restores detail sequence on synthetic data, and the patched canvas preserves detail. This does not establish the result for the user's microscopy image or every Fiji installation; no Intel runtime control was available.
Live native Retina comparison
Using the official Fiji-bundled Azul Zulu 21.0.7+6 ARM64 runtime, a side-by-side AWT diagnostic displayed baseline
4c4975d6and patchedfd942d4acanvases with the same 512×512 one-pixel checkerboard at 50% zoom. The diagnostic subclass delegates toImageCanvas.paintand does not overrideCanvas.createImage, so the baseline uses a real macOS canvas peer. Actual incoming graphics and graphics-configuration default transforms both reportedscale(2,2).Screenshots of the live window were inspected for three states:
The saved 1300×782 window captures are JPEGs. Comparing matched 300×300 image-interior regions away from the ROI and controls, adding the ROI changed 90,000/90,000 baseline screenshot pixels and 0/90,000 patched screenshot pixels. After clearing, both regions matched their no-ROI capture exactly. These are measurements of decoded screenshot pixels, separate from the headless raster measurements below; JPEG color values are not source-image pixel values. The source is synthetic and non-sensitive. Native-peer offscreen backing dimensions were not measured in this live comparison; the raster sizes in the next table are headless measurements. The harness uses
ImageCanvasin an AWT frame rather than the full Fiji application UI.Deterministic raster comparison
A deterministic headless AWT test on native ARM64 does reproduce the logical-buffer loss using a synthetic one-pixel checkerboard. The test overrides
Canvas.createImagewith a logical-resolutionBufferedImage; this deliberately tests a defined raster behavior, not the undocumented backing behavior of a particular macOS AWT peer.At 50% zoom on a simulated 2× destination:
4c4975d6)In these headless measurements, the target transform was explicitly
scale(2,2)and the graphics configuration default transform was identity. Thus the patch uses the actual destination transform, not a hard-coded Retina multiplier or a platform/architecture switch.Validation
mvn packagewith workspace-local Temurin 11.0.32.1 ARM64: passes. ProductionImageCanvas.classremains Java 6 bytecode (major 50); no newer production APIs added.maven.compiler.releaseproperty (For input string: ""in testCompile). The same failure was reproduced on an untouched archived checkout of base4c4975d6. No POM change is included. Focused tests were compiled separately against the Maven-built production classes and run with-Djava.awt.headless=true.git diff --check: passes.Standalone test command after
mvn package(JDK 11, with JUnit and Hamcrest on$TEST_LIBS):Remaining validation / tradeoffs
The real-peer Retina diagnostic confirms the ROI-triggered loss and its correction on synthetic input with the Fiji-bundled ARM runtime. Validation on the reported microscopy image, the full Fiji UI, native-peer backing dimensions, direct-paint bypass, other installed JDKs on a live display, Intel/Rosetta control, multi-monitor moves, interactive ROI handles/hit testing and flicker/performance remain untested. Live ROI types beyond the rectangle were not exercised; the wider ROI matrix is headless. Arbitrary rotated/sheared graphics and very large-buffer memory pressure are not covered; a 2× raster uses roughly four times the backing pixels. The added tests compare image interiors, not complete UI fidelity.
Ready for upstream review with the limits above. The current commit is signed with the author's existing GPG key. GitHub Actions run
36937838743for exact HEADfd942d4a737a190b7daab85dd18ed9c845e22ebaisaction_required, awaiting maintainer approval; no upstream CI pass is claimed. No merge requested.