2024-03-29 12:57 UTC

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0002580NetSurfGTK-specificpublic2018-08-29 14:04
ReporterFelix S. 
Assigned To 
SeverityminorReproducibilityalways 
StatusclosedResolutionfixed 
Product Version3.7 
Target Version3.8Fixed in Version3.8 
Summary0002580: Botched pixel format conversion corrupts librsvg-rendered images
DescriptionSVG images rendered by NetSurf with the librsvg backend appear split into two parts, at one third of the image width. Both parts are wrongly coloured. The reason for this is a mistake in the image rendering code, specifically the routine which converts the rendered output into the pixel format used internally by NetSurf.
Steps To Reproduce0. Compile NetSurf with the librsvg backend enabled.
1. Open a random page with an SVG image embedded.
2. Observe the rendering.
Additional InformationAttached patch fixes the issue. The fixed code uses a uint8_t[4]/uint32_t union in order to avoid relying on target endianness (cairo's pixel format uses native 32-bit integers, NetSurf's uses a fixed order of 8-bit channels)
TagsNo tags attached.
Fixed in CI build #4289
Reported in CI build #
URL of problem pagehttps://upload.wikimedia.org/wikipedia/commons/2/24/Euler_and_Venn_diagrams.svg
Attached Files
  • patch file icon netsurf-rsvg.patch (735 bytes) 2017-12-06 15:39 -
    --- a/content/handlers/image/rsvg.c
    +++ b/content/handlers/image/rsvg.c
    @@ -138,16 +138,20 @@ static bool rsvg_process_data(struct content *c, const char *data,
     static inline void rsvg_argb_to_abgr(uint8_t *pixels, 
     		int width, int height, size_t rowstride)
     {
    -	uint8_t *p = pixels;
    +	unsigned char *p = (void *)pixels;
     
     	for (int y = 0; y < height; y++) {
     		for (int x = 0; x < width; x++) {
    -			/* Swap R and B */
    -			const uint8_t r = p[x+3];
    -
    -			p[x+3] = p[x];
    -
    -			p[x] = r;
    +			union {
    +				uint8_t ch[4];
    +				uint32_t col;
    +			} *px = (void *)&p[x*4], npx;
    +
    +			npx.ch[0] = px->col >> 16;
    +			npx.ch[1] = px->col >> 8;
    +			npx.ch[2] = px->col;
    +			npx.ch[3] = px->col >> 24;
    +			*px = npx;
     		}
     
     		p += rowstride;
    
    patch file icon netsurf-rsvg.patch (735 bytes) 2017-12-06 15:39 +

-Relationships
+Relationships

-Notes
John-Mark Bell

~0001706

John-Mark Bell (administrator)

Thanks for the report. This is now fixed.
Vincent Sanders

~0001841

Vincent Sanders (administrator)

Thank you for your report, this has been resolved in the 3.8 release
+Notes

-Issue History
Date Modified Username Field Change
2017-12-06 15:39 Felix S. New Issue
2017-12-06 15:39 Felix S. File Added: netsurf-rsvg.patch
2018-01-20 15:34 John-Mark Bell Note Added: 0001706
2018-01-20 15:35 John-Mark Bell Product Version => 3.7
2018-01-20 15:35 John-Mark Bell Fixed in Version => 3.8
2018-01-20 15:35 John-Mark Bell Target Version => 3.8
2018-01-20 15:35 John-Mark Bell Steps to Reproduce Updated View Revisions
2018-01-20 15:35 John-Mark Bell Fixed in CI build # => 4289
2018-01-20 15:35 John-Mark Bell Status new => resolved
2018-01-20 15:35 John-Mark Bell Resolution open => fixed
2018-08-29 14:04 Vincent Sanders Status resolved => closed
2018-08-29 14:04 Vincent Sanders Note Added: 0001841
+Issue History