Skip to content

Perceptual precision causing differences to be missed in Bitrise CI due to failing CIContext.render() calls #710

@knellr

Description

@knellr

Describe the bug

When running with perceptual precision < 1 we are observing that comparisons are picking up failures correctly locally, but are passing incorrectly on Bitrise CI.

To Reproduce

Run a snapshot test in Bitrise that is expected to fail with a perceptualPrecision < 1, for example as shown in the following project:

SnapshotIssue.zip

The issue appears to be with the following code (and similar) not updating the averagePixel var. Because it's initialised as zero, the tests pass - see

  var averagePixel: Float = 0
  let context = CIContext(options: [.workingColorSpace: NSNull(), .outputColorSpace: NSNull()])
  context.render(
    thresholdOutputImage.applyingFilter("CIAreaAverage", parameters: [kCIInputExtentKey: new.extent]),
    toBitmap: &averagePixel,
    rowBytes: MemoryLayout<Float>.size,
    bounds: CGRect(x: 0, y: 0, width: 1, height: 1),
    format: .Rf,
    colorSpace: nil
  )

I'm not familiar with this call and this may be a Bitrise specific issue as they're running in VMs (I have raised a ticket with Bitrise) but I think it should be possible to make the tests fail if this scenario is hit.

Expected behavior

Test should fail

Environment

  • swift-snapshot-testing version 1.11.0
  • Xcode 14.2
  • Swift 5.7
  • OS: iOS 16

Additional context

xctestresult for Incorrectly passing run (Bitrise):

Test-SnapshotIssue.xcresult.zip

Logs

xcodebuild_test.log

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions