iOS port, expanded SVG filter pipeline, WebKit PSNR test harness#15
Open
duncanwilcox wants to merge 1 commit into
Open
iOS port, expanded SVG filter pipeline, WebKit PSNR test harness#15duncanwilcox wants to merge 1 commit into
duncanwilcox wants to merge 1 commit into
Conversation
This consolidates ~55 patches accumulated in Sitely's tree since 2024.
The themes:
iOS / iPadOS port
- New IJSVGPlatform.{h,m} centralizes macOS/iOS differences: AppKit/UIKit
imports, NSColor/Image/View/Font/BezierPath shims, geometry typedefs
and macros, NSValue (IJSVGGeometry) category bridging NS-named methods
to their CG-named iOS counterparts, and a UIView (IJSVGNeedsDisplay)
category exposing a BOOL-taking -setNeedsDisplay: shim.
- New IJSVGiOSXML.{h,m} provides a libxml2-backed
NSXMLNode/Element/Document replacement for iOS (Foundation on iOS
doesn't ship NSXML*).
- Existing headers migrated from direct <AppKit/AppKit.h> +
<Foundation/Foundation.h> imports to <IJSVG/IJSVGPlatform.h>.
- Sitely.h indirection removed from framework headers; NSGraphicsGetCurrentContext
is provided by IJSVGPlatform (inline on macOS, UIGraphicsGetCurrentContext
on iOS).
SVG filter pipeline (biggest body of work)
- Filter graph + 7 filter effects on top of the existing
IJSVGFilterEffectGaussianBlur: IJSVGFilterEffectBlend, ColorMatrix,
Composite, DisplacementMap, Flood, Lighting, Merge, Offset, Turbulence;
plus IJSVGFilterGraph orchestrating the pipeline with CALayer→bitmap
replacement rendering.
- filterUnits parsing and filter region attributes honored so SVGs
with missing attributes no longer trigger huge-bitmap allocations.
- feOffset rendering fixed; filter export round-trip works.
- Filter rasterization respects the root viewBox transform.
- Filter layer CGImage lifetime made safe across redraws.
- Filter region stabilized at 10% with vImage edge extension.
- Filter-before-opacity rendering: source graphic rendered at full
opacity (+26 dB on the gradient-filter baseline).
- Blur calibration matching WebKit (CIGaussianBlur with padded source
bitmap, after experimenting with a vImage 3-pass box blur path).
- Turbulence Y-flip corrected.
Gradients / patterns / masks
- spreadMethod="reflect" implemented for linear gradients
(+15.8 dB on the car baseline).
- Gradient mask rendering works (masks with gradient content).
- SVG viewport, gradient, and pattern regressions resolved.
- Pattern image transform handling improved.
- Clip-path transform propagation fixed.
- Imported upstream gradient-stop-parsing fixes.
Color space
- All deviceRGB references converted to sRGB throughout the framework.
- rgb() colors use sRGB (+9 dB on the tommek car baseline).
Parser robustness
- Forward-reference prescan so <use> inside <clipPath> can target
elements defined later in the document.
- Realloc bug fixed for SVGs with more than 5 transforms.
- NaN/Inf attribute workarounds in gradient parsing.
- IJSVGParser crash on certain SVGs ("circled-arrow-left.svg") fixed.
- IJSVGExporter crashes fixed.
CoreAnimation / memory / stability
- Background-thread CATransaction crash patched.
- Numerous memory leaks fixed.
- @available guards added for APIs not available in 10.14.4 / iOS 17.
- All in-framework logging removed.
Test harness (in IJSVGExample)
- New IJSVGWebKitPSNRTests.m: renders an SVG with IJSVG and snapshots
the same SVG in a WKWebView, writes IJSVG/WebKit/diff PNGs and a
PSNR results log. Overridable via IJSVG_OUTPUT_DIR and
IJSVG_WEBKIT_SETTLE_DELAY env vars.
- IJSVGExampleTests converted to a standalone (logic) test bundle:
TEST_HOST/BUNDLE_LOADER removed, IJSVG.framework linked directly and
embedded in the .xctest bundle, SVG resources bundled in the test
target, scheme promoted from xcuserdata to xcshareddata.
- WebKit.framework linked into the test target.
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.
This consolidates ~55 patches accumulated against IJSVG in Sitely's tree since 2024. The themes:
iOS / iPadOS port
IJSVGPlatform.{h,m}centralizes macOS/iOS differences: AppKit/UIKit imports,NSColor/NSImage/NSView/NSFont/NSBezierPathshims, geometry typedefs and macros, anNSValue (IJSVGGeometry)category bridging NS-named methods to their CG-named iOS counterparts, and aUIView (IJSVGNeedsDisplay)category exposing a BOOL-taking-setNeedsDisplay:shim.IJSVGiOSXML.{h,m}provides a libxml2-backedNSXMLNode/Element/Documentreplacement for iOS (Foundation on iOS doesn't shipNSXML*).<AppKit/AppKit.h>+<Foundation/Foundation.h>imports to<IJSVG/IJSVGPlatform.h>.SVG filter pipeline (biggest body of work)
IJSVGFilterEffectGaussianBlur:Blend,ColorMatrix,Composite,DisplacementMap,Flood,Lighting,Merge,Offset,Turbulence; plusIJSVGFilterGraphorchestrating the pipeline with CALayer → bitmap replacement rendering.filterUnitsparsing and filter region attributes honored so SVGs with missing attributes no longer trigger huge-bitmap allocations.feOffsetrendering fixed; filter export round-trip works.CGImagelifetime made safe across redraws.CIGaussianBlurwith padded source bitmap, after experimenting with a vImage 3-pass box blur path).Gradients / patterns / masks
spreadMethod="reflect"implemented for linear gradients (+15.8 dB on the car baseline).Color space
deviceRGBreferences converted to sRGB throughout the framework.rgb()colors use sRGB (+9 dB on the tommek car baseline).Parser robustness
<use>inside<clipPath>can target elements defined later in the document.IJSVGParsercrash on certain SVGs ("circled-arrow-left.svg") fixed.IJSVGExportercrashes fixed.CoreAnimation / memory / stability
CATransactioncrash patched.@availableguards added for APIs not available in 10.14.4 / iOS 17.Test harness (in IJSVGExample)
IJSVGWebKitPSNRTests.m: renders an SVG with IJSVG and snapshots the same SVG in aWKWebView, writes IJSVG/WebKit/diff PNGs and a PSNR results log. Overridable viaIJSVG_OUTPUT_DIRandIJSVG_WEBKIT_SETTLE_DELAYenv vars.IJSVGExampleTestsconverted to a standalone (logic) test bundle:TEST_HOST/BUNDLE_LOADERremoved,IJSVG.frameworklinked directly and embedded in the.xctestbundle, SVG resources bundled in the test target, scheme promoted fromxcuserdatatoxcshareddata.WebKit.frameworklinked into the test target.