Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Screenshots verification fails with InvocationTargetException #656

Open
LloydBlv opened this issue Feb 15, 2025 · 7 comments
Open

Screenshots verification fails with InvocationTargetException #656

LloydBlv opened this issue Feb 15, 2025 · 7 comments

Comments

@LloydBlv
Copy link

LloydBlv commented Feb 15, 2025

All screenshot tests fail on the CI in Github actions on a self-hosted runner, what could be the issue?

They run very well on my mac developer machine

Running:

Roborazzi 1.41.0
Robolectric 4.14.1

java.lang.InternalError: java.lang.reflect.InvocationTargetException
	at java.desktop/sun.font.FontManagerFactory$1.run(FontManagerFactory.java:87)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
	at java.desktop/sun.font.FontManagerFactory.getInstance(FontManagerFactory.java:75)
	at java.desktop/java.awt.Font.getFont2D(Font.java:526)
	at java.desktop/java.awt.Font.defaultLineMetrics(Font.java:2398)
	at java.desktop/java.awt.Font.getLineMetrics(Font.java:2505)
	at java.desktop/java.awt.font.TextLayout.fastInit(TextLayout.java:597)
	at java.desktop/java.awt.font.TextLayout.<init>(TextLayout.java:392)
	at com.github.takahirom.roborazzi.AwtRoboCanvas$Companion.generateCompareCanvas$drawStringWithBackgroundRect(AwtRoboCanvas.kt:447)
	at com.github.takahirom.roborazzi.AwtRoboCanvas$Companion.generateCompareCanvas(AwtRoboCanvas.kt:471)
	at com.github.takahirom.roborazzi.RoborazziKt.processOutputImageAndReportWithDefaults$lambda$23(Roborazzi.kt:702)
	at com.github.takahirom.roborazzi.ProcessOutputImageAndReportKt.processOutputImageAndReport(processOutputImageAndReport.kt:102)
	at com.github.takahirom.roborazzi.RoborazziKt.processOutputImageAndReportWithDefaults(Roborazzi.kt:686)
	at com.github.takahirom.roborazzi.RoborazziKt$captureRoboImage$2$1.invoke(Roborazzi.kt:333)
	at com.github.takahirom.roborazzi.RoborazziKt$captureRoboImage$2$1.invoke(Roborazzi.kt:326)
	at com.github.takahirom.roborazzi.RoborazziKt.capture(Roborazzi.kt:666)
	at com.github.takahirom.roborazzi.RoborazziKt$captureRoboImage$2.invoke(Roborazzi.kt:326)
	at com.github.takahirom.roborazzi.RoborazziKt$captureRoboImage$2.invoke(Roborazzi.kt:322)
	at com.github.takahirom.roborazzi.RoborazziKt.captureScreenIfMultipleWindows(Roborazzi.kt:190)
	at com.github.takahirom.roborazzi.RoborazziKt.captureRoboImage(Roborazzi.kt:322)
	at com.github.takahirom.roborazzi.RoborazziKt.captureRoboImage(Roborazzi.kt:314)
	at com.github.takahirom.roborazzi.RoborazziKt.captureRoboImage$default(Roborazzi.kt:309)
	at com.example.testSnapshot(TestSnapshots.kt:40)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:569)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:54)
	at androidx.compose.ui.test.junit4.AndroidComposeTestRule$apply$1$evaluate$1.invoke(AndroidComposeTestRule.android.kt:272)
	at androidx.compose.ui.test.junit4.AndroidComposeTestRule$apply$1$evaluate$1.invoke(AndroidComposeTestRule.android.kt:271)
	at androidx.compose.ui.test.AndroidComposeUiTestEnvironment$AndroidComposeUiTestImpl.withDisposableContent(ComposeUiTest.android.kt:495)
	at androidx.compose.ui.test.AndroidComposeUiTestEnvironment$runTest$1$1$1$1$1$1.invoke(ComposeUiTest.android.kt:327)
	at androidx.compose.ui.test.AndroidComposeUiTestEnvironment.withComposeIdlingResource(ComposeUiTest.android.kt:379)
	at androidx.compose.ui.test.AndroidComposeUiTestEnvironment.access$withComposeIdlingResource(ComposeUiTest.android.kt:230)
	at androidx.compose.ui.test.AndroidComposeUiTestEnvironment$runTest$1$1$1$1$1.invoke(ComposeUiTest.android.kt:326)
	at androidx.compose.ui.test.AndroidComposeUiTestEnvironment.withWindowRecomposer(ComposeUiTest.android.kt:353)
	at androidx.compose.ui.test.AndroidComposeUiTestEnvironment.access$withWindowRecomposer(ComposeUiTest.android.kt:230)
	at androidx.compose.ui.test.AndroidComposeUiTestEnvironment$runTest$1$1$1$1.invoke(ComposeUiTest.android.kt:325)
	at androidx.compose.ui.test.AndroidComposeUiTestEnvironment.withTestCoroutines(ComposeUiTest.android.kt:366)
	at androidx.compose.ui.test.AndroidComposeUiTestEnvironment.access$withTestCoroutines(ComposeUiTest.android.kt:230)
	at androidx.compose.ui.test.AndroidComposeUiTestEnvironment$runTest$1$1$1.invoke(ComposeUiTest.android.kt:324)
	at androidx.compose.ui.test.junit4.IdlingStrategy.withStrategy(IdlingStrategy.android.kt:52)
	at androidx.compose.ui.test.AndroidComposeUiTestEnvironment$runTest$1$1.invoke(ComposeUiTest.android.kt:323)
	at androidx.compose.ui.test.junit4.IdlingResourceRegistry.withRegistry(IdlingResourceRegistry.jvm.kt:157)
	at androidx.compose.ui.test.AndroidComposeUiTestEnvironment$runTest$1.invoke(ComposeUiTest.android.kt:322)
	at androidx.compose.ui.test.junit4.ComposeRootRegistry.withRegistry(ComposeRootRegistry.android.kt:146)
	at androidx.compose.ui.test.AndroidComposeUiTestEnvironment.runTest(ComposeUiTest.android.kt:321)
	at androidx.compose.ui.test.junit4.AndroidComposeTestRule$apply$1.evaluate(AndroidComposeTestRule.android.kt:271)
	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
	at org.robolectric.RobolectricTestRunner$HelperTestRunner$1.evaluate(RobolectricTestRunner.java:502)
	at org.robolectric.internal.SandboxTestRunner$2.lambda$evaluate$2(SandboxTestRunner.java:285)
	at org.robolectric.internal.bytecode.Sandbox.lambda$runOnMainThread$0(Sandbox.java:104)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
	at java.desktop/sun.font.FontManagerFactory$1.run(FontManagerFactory.java:85)
	... 59 more
Caused by: java.lang.RuntimeException: Fontconfig head is null, check your fonts or fonts configuration
	at java.desktop/sun.awt.FontConfiguration.getVersion(FontConfiguration.java:1271)
	at java.desktop/sun.awt.FontConfiguration.readFontConfigFile(FontConfiguration.java:224)
	at java.desktop/sun.awt.FontConfiguration.init(FontConfiguration.java:106)
	at java.desktop/sun.awt.X11FontManager.createFontConfiguration(X11FontManager.java:706)
	at java.desktop/sun.font.SunFontManager$2.run(SunFontManager.java:358)
	at java.desktop/sun.font.SunFontManager$2.run(SunFontManager.java:315)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
	at java.desktop/sun.font.SunFontManager.<init>(SunFontManager.java:315)
	at java.desktop/sun.awt.FcFontManager.<init>(FcFontManager.java:35)
	at java.desktop/sun.awt.X11FontManager.<init>(X11FontManager.java:56)
	.
@takahirom
Copy link
Owner

Thanks. I haven't encountered this specific issue before. It might relate to font availability in your environment. Would you mind sharing your JDK version and OS information to help investigate further?

@LloydBlv
Copy link
Author

Thanks. I haven't encountered this specific issue before. It might relate to font availability in your environment. Would you mind sharing your JDK version and OS information to help investigate further?

Thanks for your quick response 🙏 It's 17 Zulu and CentOS

@takahirom
Copy link
Owner

I recommend installing the "Courier New" font, though it might not be the optimal solution. To address this, I plan to implement a fix that defaults to the system font when "Courier New" isn't available. However, this approach also presents challenges, as the font affects image generation (particularly when using Roborazzi's dump feature) and could lead to visual inconsistencies.
https://help.accusoft.com/PCC/v8.4/HTML/How%20to%20Install%20Microsoft%20Fonts%20on%20Linux.html

#657

@LloydBlv
Copy link
Author

I recommend installing the "Courier New" font, though it might not be the optimal solution. To address this, I plan to implement a fix that defaults to the system font when "Courier New" isn't available. However, this approach also presents challenges, as the font affects image generation (particularly when using Roborazzi's dump feature) and could lead to visual inconsistencies. https://help.accusoft.com/PCC/v8.4/HTML/How%20to%20Install%20Microsoft%20Fonts%20on%20Linux.html

#657

Installed this but still same result ☹

@LloydBlv
Copy link
Author

I recommend installing the "Courier New" font, though it might not be the optimal solution. To address this, I plan to implement a fix that defaults to the system font when "Courier New" isn't available. However, this approach also presents challenges, as the font affects image generation (particularly when using Roborazzi's dump feature) and could lead to visual inconsistencies. https://help.accusoft.com/PCC/v8.4/HTML/How%20to%20Install%20Microsoft%20Fonts%20on%20Linux.html
#657

Installed this but still same result ☹

Maybe it helps for debugging, Tried Paparazzi, at first it did not work with Robolectric included, removed robolectric and it worked fine

@takahirom
Copy link
Owner

Thank you for the information. In addition to supporting fallback to a monospace font, I plan to make the font customizable.
https://github.com/takahirom/roborazzi/pull/657/files#diff-8ccf7b240375e51ef5939891351826d94c7d9adc1e9f32cc6b600d0754b3100cR559

@takahirom
Copy link
Owner

@LloydBlv
I've released 1.42.0
Could you check it out?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants