Skip to content

Paywalls: use HEIC images#3496

Merged
NachoSoto merged 2 commits into
mainfrom
paywalls-heic
Dec 7, 2023
Merged

Paywalls: use HEIC images#3496
NachoSoto merged 2 commits into
mainfrom
paywalls-heic

Conversation

@NachoSoto

Copy link
Copy Markdown
Contributor

This is a performance optimization.

@aboedo

aboedo commented Dec 6, 2023

Copy link
Copy Markdown
Member

looks great! Maybe we should fall back to the old key if the new one is not found while we figure out how to migrate the existing images?

@aboedo

aboedo commented Dec 6, 2023

Copy link
Copy Markdown
Member

might not be worth it given that it's a bigger refactor, depending on how things go migration-wise

@NachoSoto

Copy link
Copy Markdown
Contributor Author

@aboedo done

NachoSoto added a commit to RevenueCat/purchases-android that referenced this pull request Dec 7, 2023
Performance optimization equivalent to RevenueCat/purchases-ios#3496

set {
self._imagesHeic = newValue
self._legacyImages = nil

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also, when would this setter be called?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This preserves the semantics of the setter.
Imagine a given configuration:

var config = Configuration(
  imagesHeic: Images(...),
  legacyImages: Images(...)
)

Doing this:

config.images.background = "new"

Is equivalent in Swift to this:

var newImages = config.images // This is getting the "derived" getter, merging both
newImages.background = "new"
config.images = newImages

This implementation is tested in a new test to verify its correctness too. Basically, not removing _legacyImages would mean you can't do this:

config.images.background = nil

Because it would potentially still find the fallback in legacyImages. This setter is mainly used for tests. Everywhere else we use immutable PaywallData so the setter isn't accessible anyway.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I see! Thanks for taking the time to write that up

@NachoSoto NachoSoto Dec 7, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Learning (some) Kotlin made me realize that these sorts of things are nothing but obvious when learning a new language 😇

"display_restore_purchases" : true,
"images" : {
"images_heic" : {
"background" : "background.jpg",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

do these need to be updated to background.heic?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That comes from this:

static let backgroundImage = "background.jpg"

The background image embedded in the framework is jpg. When creating a custom PaywallData.Configuration I chose to set images_heic instead of images, so it gets serialized like this.

expect(paywall.config.images) == .init(
header: "header.jpg",
header: "header.heic",
background: "background.jpg",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why is the background not heic?

@NachoSoto NachoSoto Dec 7, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Same as above.

NachoSoto added a commit to RevenueCat/purchases-android that referenced this pull request Dec 7, 2023
Performance optimization equivalent to
RevenueCat/purchases-ios#3496
@codecov

codecov Bot commented Dec 7, 2023

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 93.33333% with 1 line in your changes missing coverage. Please review.

Project coverage is 86.07%. Comparing base (56daf52) to head (bf2531f).
Report is 415 commits behind head on main.

Files with missing lines Patch % Lines
Sources/Paywalls/PaywallData.swift 93.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3496      +/-   ##
==========================================
+ Coverage   86.06%   86.07%   +0.01%     
==========================================
  Files         237      237              
  Lines       17212    17226      +14     
==========================================
+ Hits        14813    14827      +14     
  Misses       2399     2399              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@joshdholtz joshdholtz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me!

@NachoSoto NachoSoto merged commit 0436134 into main Dec 7, 2023
@NachoSoto NachoSoto deleted the paywalls-heic branch December 7, 2023 18:30
NachoSoto pushed a commit that referenced this pull request Dec 12, 2023
**This is an automatic release.**

### RevenueCatUI
* `Paywalls`: improve image caching (#3498) via NachoSoto (@NachoSoto)
* `Paywalls`: change style of CTA button to be consistent with other
platforms (#3507) via NachoSoto (@NachoSoto)
* `Paywalls`: open footer links on Safari on Catalyst (#3508) via
NachoSoto (@NachoSoto)
* `Paywalls`: fix compilation on Xcode < 14.3 (#3513) via NachoSoto
(@NachoSoto)
* Fix typo in zh-Hans localization of RevenueCatUI (#3512) via Francis
Feng (@francisfeng)
* `Paywalls`: fix PaywallViewControllerDelegate access from Objective-C
(#3510) via noncenz (@noncenz)
* `Paywalls`: open Terms and Privacy Policy links in-app (#3475) via
Andy Boedo (@aboedo)
* `Paywalls`: fix empty description when using `custom` package type and
`{{ sub_period }}` (#3495) via Andy Boedo (@aboedo)
* `Paywalls`: use `HEIC` images (#3496) via NachoSoto (@NachoSoto)
* Paywalls: disable the close button when an action is in progress
(#3474) via Andy Boedo (@aboedo)
* `Paywalls`: adjusted German translations (#3476) via Tensei (@tensei)
* Paywalls: Improve Chinese localization (#3489) via Andy Boedo
(@aboedo)
### Other Changes
* `CircleCI`: add git credentials to snapshot generation (#3506) via
NachoSoto (@NachoSoto)
* `StoreProduct`: improve `priceFormatter` documentation (#3500) via
NachoSoto (@NachoSoto)
* `Paywalls`: fix tests (#3499) via NachoSoto (@NachoSoto)
* `Optimization`: changed `first` to `first(where:)` (#3467) via
NachoSoto (@NachoSoto)
@vegaro vegaro added pr:other and removed pr:perf labels Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants