nativescript-community / ui-image

Advanced and efficient image display plugin which uses Fresco (Android) and SDWebImage (iOS) to implement caching, placeholders, image effects, and much more.
Apache License 2.0
36 stars 9 forks source link

[iOS] Disk cache is not used #26

Closed benediktveith closed 4 years ago

benediktveith commented 4 years ago

Which platform(s) does your issue occur on?

Please, provide the following version numbers that your issue occurs with:

"nativescript-image": "^3.0.5"

Plugins

    "fs-extra": "^7.0.0",
    "lodash": "^4.17.11",
    "moment": "^2.23.0",
    "mout": "^1.1.0",
    "nativescript-background-http": "^4.0.0",
    "nativescript-bitmap-factory": "^1.8.1",
    "nativescript-camera": "^4.5.0",
    "nativescript-image": "^3.0.5",
    "nativescript-imagepicker": "^7.1.0",
    "nativescript-iqkeyboardmanager": "^1.4.0",
    "nativescript-local-notifications": "^4.0.1",
    "nativescript-microsoft-appcenter": "^2.0.0",
    "nativescript-permissions": "^1.3.7",
    "nativescript-plugin-firebase": "9.0.4",
    "nativescript-swift-4.0": "git+https://github.com/samtheprogram/nativescript-swift-4.0.git",
    "nativescript-textinputlayout-v2": "^2.0.8",
    "nativescript-theme-core": "^1.0.4",
    "nativescript-ui-listview": "8.1.2",
    "nativescript-vue": "^2.6.0",
    "nativescript-webview-utils": "^3.0.0",
    "tns-core-modules": "6.3.2",
    "vue-gettext": "^2.0.31",
    "vuex": "^3.0.1"

Podfile

use_frameworks!

target "boommobile" do
# Begin Podfile - /Users/benediktveith/Apps/Nativescript/boom-mobile/node_modules/nativescript-imagepicker/platforms/ios/Podfile
pod 'QBImagePickerController', '~> 3.4.0'
# End Podfile

# Begin Podfile - /Users/benediktveith/Apps/Nativescript/boom-mobile/node_modules/nativescript-iqkeyboardmanager/platforms/ios/Podfile
pod 'IQKeyboardManager', '~> 6.2.0'

# End Podfile

# Begin Podfile - /Users/benediktveith/Apps/Nativescript/boom-mobile/node_modules/nativescript-microsoft-appcenter/platforms/ios/Podfile
pod 'AppCenter'
pod 'AppCenter/Distribute'
# End Podfile

# NativeScriptPlatformSection /Users/benediktveith/Apps/Nativescript/boom-mobile/node_modules/nativescript-plugin-firebase/platforms/ios/Podfile with 9.0
platform :ios, '9.0'
# End NativeScriptPlatformSection

# Begin Podfile - /Users/benediktveith/Apps/Nativescript/boom-mobile/node_modules/nativescript-plugin-firebase/platforms/ios/Podfile
# platform :ios, '9.0'

# With NativeScript < 5.2 we can't bump Firebase/Core beyond 5.15.0, but with 5.2+ we can
pod 'Firebase/Core', '~> 6.2.0'

# Authentication
#pod 'Firebase/Auth'

# Realtime DB
#pod 'Firebase/Database'

# Cloud Firestore (sticking to 0.14 for now because of build error - see https://github.com/firebase/firebase-ios-sdk/issues/2177)
#pod 'FirebaseFirestore', '~> 0.14.0'
# .. unless the modern build system is supported, then we can use the latest version (NativeScript 5.2+)
#pod 'Firebase/Firestore'

# Remote Config
#pod 'Firebase/RemoteConfig'

# Performance Monitoring
#pod 'Firebase/Performance'

# Crashlytics
#pod 'Fabric'
#pod 'Crashlytics'

# Firebase Cloud Messaging (FCM)
pod 'Firebase/Messaging'

# Firebase In-App Messaging (supported on NativeScript 5.2+)
#pod 'Firebase/InAppMessagingDisplay'

# Firebase Cloud Storage
#pod 'Firebase/Storage'

# Firebase Cloud Functions
#pod 'Firebase/Functions'

# AdMob
#pod 'Firebase/AdMob'

# Dynamic Links
#pod 'Firebase/DynamicLinks'

# ML Kit
#pod 'Firebase/MLVision'
#pod 'Firebase/MLVisionTextModel'
#pod 'Firebase/MLVisionBarcodeModel'
#pod 'Firebase/MLVisionFaceModel'
#pod 'Firebase/MLVisionLabelModel'
#pod 'Firebase/MLModelInterpreter'
#pod 'Firebase/MLNaturalLanguage'
#pod 'Firebase/MLNLLanguageID'
#pod 'Firebase/MLCommon'
#pod 'Firebase/MLNLSmartReply'

# Facebook Authentication
#pod 'FBSDKCoreKit'
#pod 'FBSDKLoginKit'

# Google Authentication
#pod 'GoogleSignIn'
# End Podfile

post_install do |installer|
  post_installnativescript_swift_4_0_0 installer
end

# Begin Podfile - /Users/benediktveith/Apps/Nativescript/boom-mobile/node_modules/nativescript-swift-4.0/platforms/ios/Podfile

def post_installnativescript_swift_4_0_0 (installer)
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['SWIFT_VERSION'] = '4.0'
    end
  end
end

# End Podfile

# Begin Podfile - /Users/benediktveith/Apps/Nativescript/boom-mobile/node_modules/nativescript-textinputlayout-v2/platforms/ios/Podfile
pod 'SkyFloatingLabelTextField', '~> 3.6.0'
# End Podfile

# Begin Podfile - /Users/benediktveith/Apps/Nativescript/boom-mobile/node_modules/@nativescript/core/platforms/ios/Podfile
# platform :ios, '9.0'
use_frameworks!

pod 'MaterialComponents/Tabs', '~> 94.5'
# End Podfile

# Begin Podfile - /Users/benediktveith/Apps/Nativescript/boom-mobile/node_modules/nativescript-image/platforms/ios/Podfile
pod 'SDWebImage', '>= 5.6.1'

# End Podfile
end

The bug

If I have no network connection on iOS the images are not loaded, even though the images are cached on the disk: isInDiskCache(key) returns true, but failureImageUri is used.

farfromrefug commented 4 years ago

@benediktveith please add informations about versions (plugins, pods...) Could you please create a simple example to reproduce? Thanks

benediktveith commented 4 years ago

@farfromrefug Added the plugins / pods above.

Hmm I retested the plugin in an empty project and it is working there. Seems like the bug is caused because of the uri I am using.

It is basically an endpoint which provides an image as response (something like: xyz.com/image/1234-5678

farfromrefug commented 4 years ago

@benediktveith ok so a few things:

benediktveith commented 4 years ago

@farfromrefug Hey,

Doesn't matter anymore, I investigated further and realised it is working if I am using a domain name instead of my IP-Adress. To explain it a little bit more:

For local device testing (iOS / Android) I am using the IP-Adress of my Mac (192.168.178.XX). If I change the url to, for example, projectname.local, which is the ServerName of one of my virtual hosts running locally, it is working as expected.

Thanks for your fast replies btw :)