mapbox-navigation-ios icon indicating copy to clipboard operation
mapbox-navigation-ios copied to clipboard

Replace ImageCache, DataCache with URLCache

Open ShanMa1991 opened this issue 3 years ago • 5 comments

Description

This pr is to fix #3841 by replacing ImageCache, DataCache with URLCache.

Implementation

For DataCache, it's only used for the speech caching from the result of SpeechSynthesizer.audioData(with:completionHandler:) from MapboxSpeech. It only receives the data and error information. So the URLCache is not capable in this case.

For the ImageCache, when used in ImageRepository, it's only responsible for the JunctionView update, and it already supports the local disk caching. So it won't be changed.

In SpriteRepository, the previous spriteCache, legacyCache and infoCache is replaced with the derivedCache as ImageCache and requestCache of a URLCache. The requestCache is used to store downloaded Sprite image, Sprite Info and single legacy shields. The derivedCache is used to store the generated generic shields, exit views and the single sprite shield icon.

Right now the ImageDownload and ImageDownloader are updated to more generic RequestDownload and RequestDownloader. The ImageRepository and SpriteRepository will be responsible for generating urlRequest and converting data to image.

Screenshots or Gifs

ShanMa1991 avatar Jun 01 '22 22:06 ShanMa1991

Breaking Changes in MapboxNavigation

Breaking API Changes

DataCache

  • removed method: clearMemory() in DataCache
  • removed method: clearDisk(completion:) in DataCache
  • removed method: store(_:forKey:toDisk:completion:) in DataCache

store(_:forKey:toDisk:completion:)

  • removed method: store(_:forKey:toDisk:completion:)

clearMemory()

  • removed method: clearMemory()

Don't forget to add a changelog entry.

S2Ler avatar Jun 13 '22 19:06 S2Ler

Don't forget to add a changelog entry.

Because the SpriteRepository is not public, the newly added cache type is internal. There won't be any changes to users. I'm not sure what to add to the changelog.

ShanMa1991 avatar Jun 14 '22 22:06 ShanMa1991

@ShanMa1991, sorry, looks like https://github.com/mapbox/mapbox-navigation-ios/pull/4004 brought multiple conflicts with your current PR. Would you be able to resolve them? (let me know if any help is needed)

MaximAlien avatar Jul 18 '22 17:07 MaximAlien

@MaximAlien Thanks for the reminder, currently it's rebased to catch the change from #4004

ShanMa1991 avatar Jul 18 '22 19:07 ShanMa1991

Breaking Changes in MapboxNavigation

Breaking API Changes

NavigationViewControllerDelegate

  • removed method: navigationViewController(_:didSelect:) in NavigationViewControllerDelegate