Skip to content

Commit 1ea359b

Browse files
author
Jay Bhaskar
committedMar 24, 2025
8347937: Canvas pattern test fails and crashes on WebKit 620.1
Backport-of: fd099a7f067c1694c1c12a8fa02b1e7eda51201f
1 parent 4b94e82 commit 1ea359b

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed
 

‎modules/javafx.web/src/main/native/Source/WebCore/platform/graphics/ImageFrame.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,26 @@ ImageFrame::ImageFrame()
3737
ImageFrame::ImageFrame(Ref<NativeImage>&& nativeImage)
3838
: m_nativeImage(WTFMove(nativeImage))
3939
{
40+
#if PLATFORM(JAVA)
41+
/* Ref: Webkit 619.1 javafx.web/src/main/native/Source/WebCore/platform/graphics/ImageSource.cpp refactoring in 620.1
42+
*
43+
* In the case of the canvas pattern using a transform property filled with an SVGMatrix()
44+
* created by an SVG element, `frame.m_nativeImage->size()` calls `NativeImage::size()`
45+
* from NativeImageJava.cpp.
46+
*
47+
* In this scenario, `*m_platformImage->getImage().get()` may be invalid,
48+
* as the image decoder has already populated `frame.m_size` during image metadata caching.
49+
*
50+
* To avoid potential invalid accesses and unintended size resets, only update `m_size`
51+
* if the frame does not already have a valid native image.
52+
*/
53+
if (!hasNativeImage() && m_nativeImage)
54+
m_size = m_nativeImage->size();
55+
#else
4056
m_size = m_nativeImage->size();
57+
#endif
4158
m_hasAlpha = m_nativeImage->hasAlpha();
59+
4260
}
4361

4462
ImageFrame::~ImageFrame()

‎modules/javafx.web/src/test/java/test/javafx/scene/web/CanvasTest.java

-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import org.junit.jupiter.api.AfterEach;
3838
import org.junit.jupiter.api.Test;
3939
import static org.junit.jupiter.api.Assertions.*;
40-
import org.junit.jupiter.api.Disabled;
4140

4241
/**
4342
* Test the Image to DataURL function
@@ -121,7 +120,6 @@ public class CanvasTest extends TestBase {
121120
}
122121

123122
// JDK-8234471
124-
@Disabled("JDK-8347937")
125123
@Test public void testCanvasPattern() throws Exception {
126124
final String htmlCanvasContent = "\n"
127125
+ "<canvas id='canvaspattern' width='100' height='100'></canvas>\n"

0 commit comments

Comments
 (0)