Skip to content

Conversation

JZDesign
Copy link
Contributor

Checklist

  • If applicable, unit tests
  • If applicable, create follow-up issues for purchases-android and hybrids

Motivation

Description

@JZDesign JZDesign requested a review from a team as a code owner October 17, 2025 15:51
@JZDesign JZDesign added the pr:fix A bug fix label Oct 17, 2025
Copy link

emerge-tools bot commented Oct 17, 2025

📸 Snapshot Test

11 modified, 864 unchanged

Name Added Removed Modified Renamed Unchanged Errored Approval
RevenueCat
com.revenuecat.PaywallsTester
0 0 0 0 236 0 N/A
RevenueCat
com.revenuecat.PaywallsTester.mac-catalyst-optimized-for-mac
0 0 0 0 236 0 N/A
RevenueCat
com.revenuecat.PaywallsTester.mac-native
0 0 11 0 156 0 ✅ Approved
RevenueCat
com.revenuecat.PaywallsTester.mac-catalyst-scaled-to-match-ipad
0 0 0 0 236 0 N/A

🛸 Powered by Emerge Tools

@JZDesign JZDesign requested a review from a team as a code owner October 17, 2025 19:09
}

func generateLocalFilesystemURL(forRemoteURL url: URL, withChecksum checksum: Checksum?) -> URL? {
let path = checksum?.value ?? url.absoluteString.asData.md5String
Copy link
Member

Choose a reason for hiding this comment

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

Since the checksum should be unique, we don't need the md5 string of the url, correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is if we have a checksum. Images don't have one. So I'm falling back to the md5

// Set up file handling

let tempFileURL = temporaryDirectory.appendingPathExtension(checksum?.value ?? url.pathExtension)
let tempFileURL = temporaryDirectory.appendingPathComponent((checksum?.value ?? "") + url.lastPathComponent)
Copy link
Member

Choose a reason for hiding this comment

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

Instead of empty string, should this be an md5 of the url? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This file is deleted after we confirm that the download is valid and we move the contents to the permanent file location. So the md5 here matters little to me. I could even get rid of the checksum here I think. I really just need some text + the file extension. So the url.lastPathComponent would really be all I need.

I specifically need to include the .mp4 or whatever it is there because the newer build tools (pretty sure it's due to Xcode build tools now, not iOS 26) for one reason or another do not consistently render the video without the file extension.

Comment on lines +133 to +135
let path = checksum?.value ?? url.absoluteString.asData.md5String
return cacheURL?
.appendingPathComponent(url.absoluteString.asData.md5String)
.appendingPathExtension(checksum?.value ?? url.pathExtension)
.appendingPathComponent(path + url.lastPathComponent)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the fix. 2 things are different

  1. PathExtension -- putting the checksum in there was a mistake. It should have been a path component that ended with the path extension.
  2. I'm no longer chaining the calls. This seems to be a breaking change with iOS 26 (or perhaps the xcode26 build tools), the second call is ignored. Or something is severely wrong with my machine.

This results in the correct output in both Xcode 16.4 and Xcode 26

// Set up file handling

let tempFileURL = temporaryDirectory.appendingPathExtension(checksum?.value ?? url.pathExtension)
let tempFileURL = temporaryDirectory.appendingPathComponent((checksum?.value ?? "") + url.lastPathComponent)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This ended up being an issue too after changing the other file, moving didn't work. So I had to update this too.

Comment on lines +143 to +153
.onReceive(
stagedURL.publisher
.eraseToAnyPublisher()
.removeDuplicates()
.debounce(for: 0.300, scheduler: RunLoop.main)
) { output in
// in the event that the download of the high res video is so fast that it tries to set the
// url moments after the low_res was set, we need to delay a tiny bit to ensure the rerender
// actually occurs. This happens consistently with small file sizes and great connection
cachedURL = output
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was also not noticed until the editor changes merged because the high res and low res were the same file and therefore we just ignored the second one.

@JZDesign JZDesign merged commit ef3357f into main Oct 17, 2025
12 checks passed
@JZDesign JZDesign deleted the jzdesign/hotfix/cached-media branch October 17, 2025 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:fix A bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants