Skip to content

StackOverflowError in Image when auto-scaling differs from device zoom #2353

Closed

Description

@ptziegler

To Reproduce

Run Snippet367 with -Dswt.autoScale=150.

Stacktrace:

Exception in thread "main" java.lang.StackOverflowError
	at org.eclipse.swt.internal.DPIUtil.getElementAtZoom(DPIUtil.java:289)
	at org.eclipse.swt.internal.DPIUtil.validateAndGetImageDataAtZoom(DPIUtil.java:260)
	at org.eclipse.swt.graphics.Image.initFromImageDataProvider(Image.java:797)
	at org.eclipse.swt.graphics.Image.<init>(Image.java:675)
	at org.eclipse.swt.internal.DPIUtil.autoScaleImageData(DPIUtil.java:156)
	at org.eclipse.swt.internal.DPIUtil.scaleImageData(DPIUtil.java:139)
	at org.eclipse.swt.graphics.Image.initFromImageDataProvider(Image.java:798)
	at org.eclipse.swt.graphics.Image.<init>(Image.java:675)
	at org.eclipse.swt.internal.DPIUtil.autoScaleImageData(DPIUtil.java:156)
	at org.eclipse.swt.internal.DPIUtil.scaleImageData(DPIUtil.java:139)
	at org.eclipse.swt.graphics.Image.initFromImageDataProvider(Image.java:798)
	at org.eclipse.swt.graphics.Image.<init>(Image.java:675)
...

Environment:

  1. Select the platform(s) on which the behavior is seen:
    • All OS
    • Windows
    • Linux
    • macOS

Version since

This is a regression introduced with 216f1ad.

Activity

  1. added
    bugSomething isn't working
    regressionSomething that used to work
    on Jul 27, 2025
  2. changed the title [-]StackOverflowError when scaling images on Linux[/-] [+]StackOverflowError when auto-scaling images on Linux[/+] on Jul 27, 2025
  3. added and removed on Jul 27, 2025
  4. changed the title [-]StackOverflowError when auto-scaling images on Linux[/-] [+]StackOverflowError in Image when auto-scaling differs from device zoom[/+] on Jul 27, 2025
  5. ptziegler commented on Jul 27, 2025

    @ptziegler
    ContributorAuthor

    A similar issue can be reproduced on Windows, also as a result of this commit. For this, simply execute Issue0445_HiDPISmoothScaling when your device zoom is something other than 200%.

    Exception in thread "main" java.lang.StackOverflowError
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:651)
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:639)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
    at org.eclipse.swt.graphics.GC.disposeOperations(GC.java:5968)
    at org.eclipse.swt.graphics.GC.dispose(GC.java:5964)
    at org.eclipse.swt.graphics.Image$ImageGcDrawerWrapper.newImageHandle(Image.java:2613)
    at org.eclipse.swt.graphics.Image.getImageMetadata(Image.java:810)
    at org.eclipse.swt.graphics.Image$ImageGcDrawerWrapper.newImageData(Image.java:2587)
    at org.eclipse.swt.graphics.Image.getImageData(Image.java:1263)
    at org.eclipse.swt.internal.DPIUtil.autoScaleImageData(DPIUtil.java:170)
    at org.eclipse.swt.internal.DPIUtil.scaleImageData(DPIUtil.java:139)
    at org.eclipse.swt.graphics.Image$BaseImageProviderWrapper.initializeHandleFromSource(Image.java:2292)
    at org.eclipse.swt.graphics.Image$BaseImageProviderWrapper.newImageHandle(Image.java:2287)
    at org.eclipse.swt.graphics.Image.getImageMetadata(Image.java:810)
    at org.eclipse.swt.graphics.Image.win32_getHandle(Image.java:834)
    at org.eclipse.swt.graphics.Image.createGdipImage(Image.java:858)
    at org.eclipse.swt.graphics.GC.drawImage(GC.java:1201)
    at org.eclipse.swt.graphics.GC$DrawImageToImageOperation.apply(GC.java:1194)
    at org.eclipse.swt.graphics.GC.storeAndApplyOperationForExistingHandle(GC.java:5947)
    at org.eclipse.swt.graphics.GC.drawImage(GC.java:1105)
    at org.eclipse.swt.graphics.Image.drawScaled(Image.java:853)
    at org.eclipse.swt.internal.DPIUtil$1.drawOn(DPIUtil.java:161)
    at org.eclipse.swt.graphics.Image$ImageGcDrawerWrapper.newImageHandle(Image.java:2607)
    at org.eclipse.swt.graphics.Image.getImageMetadata(Image.java:810)
    at org.eclipse.swt.graphics.Image$ImageGcDrawerWrapper.newImageData(Image.java:2587)
    at org.eclipse.swt.graphics.Image.getImageData(Image.java:1263)
    at org.eclipse.swt.internal.DPIUtil.autoScaleImageData(DPIUtil.java:170)
    at org.eclipse.swt.internal.DPIUtil.scaleImageData(DPIUtil.java:139)
    ...
    
  6. added
    HiDPIIssues related to High resolution monitors
    on Jul 27, 2025
  7. HeikoKlare commented on Jul 28, 2025

    @HeikoKlare
    Contributor

    Thank you for the report! We will have a look at this as soon as possible. The original code does also not seem fully sound to me, so let's see how we can properly fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    HiDPIIssues related to High resolution monitorsbugSomething isn't workingregressionSomething that used to work

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions