Skip to content

Fix for singular matrix warning#542

Merged
marionbarker merged 1 commit intodevfrom
fix-for-singular-matrix-warning
Mar 15, 2026
Merged

Fix for singular matrix warning#542
marionbarker merged 1 commit intodevfrom
fix-for-singular-matrix-warning

Conversation

@bjorkert
Copy link
Contributor

This change prevents repeated console warnings:

CGAffineTransformInvert: singular matrix

These warnings occur when the Charts library attempts to invert a transform matrix while the chart view temporarily has zero dimensions (for example before layout is complete). In this situation the matrix is singular (determinant = 0), and calling .inverted() triggers the warning.

The fix adds a simple guard before performing the inversion. If the matrix determinant is zero, .identity is returned instead of attempting the inversion.

This is safe because a singular matrix means the chart has no meaningful size yet, so there is nothing useful to transform.

Since the code lives inside a CocoaPods dependency (Charts), the fix is applied in two ways:

  • A direct patch in Pods/Charts/Source/Charts/Utils/Transformer.swift
  • A post_install hook in the Podfile that re-applies the patch automatically when pod install runs

This removes the warnings without affecting chart rendering or behavior.

@bjorkert bjorkert requested a review from marionbarker March 15, 2026 17:56
@bjorkert
Copy link
Contributor Author

Solves: #168

@marionbarker
Copy link
Collaborator

Test

This works nicely. The singular matrix indication in debug log is gone. The Nightscout plot populates much faster.
I am no longer seeing a delay before the Loop Predication is plotted on the Home screen.

Copy link
Collaborator

@marionbarker marionbarker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved by code review and test.

@marionbarker marionbarker merged commit 7f31ef7 into dev Mar 15, 2026
@marionbarker marionbarker deleted the fix-for-singular-matrix-warning branch March 15, 2026 18:58
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

Successfully merging this pull request may close these issues.

2 participants