react-native-fast-image 10.8.2 → 10.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -77,7 +77,7 @@ To set the cache's size when the app starts, see [Native config](#native-config)
|
|
|
77
77
|
|
|
78
78
|
If your Android app has its own Glide `AppGlideModule`, read [using FastImage with an AppGlideModule](docs/android-build-settings.md#if-your-app-has-its-own-appglidemodule) first, or FastImage may not work.
|
|
79
79
|
|
|
80
|
-
If `pod install` can't find a compatible SDWebImage (FastImage needs 5.21.
|
|
80
|
+
If `pod install` can't find a compatible SDWebImage (FastImage needs 5.21.5 or later), update it with `cd ios && pod update SDWebImage`.
|
|
81
81
|
|
|
82
82
|
## Usage
|
|
83
83
|
|
package/RNFastImage.podspec
CHANGED
|
@@ -20,12 +20,12 @@ Pod::Spec.new do |s|
|
|
|
20
20
|
# TurboModule (React-Core, Codegen's output for src/specs, ...).
|
|
21
21
|
install_modules_dependencies(s)
|
|
22
22
|
|
|
23
|
-
# Any 5.x from 5.21.
|
|
23
|
+
# Any 5.x from 5.21.5, so apps can use newer versions (and share them with
|
|
24
24
|
# other libraries, such as expo-image, which uses ~> 5.21.0 from Expo SDK 53)
|
|
25
25
|
# without having to update. downsample needs 5.19.7, tinted animated images
|
|
26
|
-
# and maxDiskAge counting from an image's last use 5.20, and 5.21.4
|
|
27
|
-
#
|
|
28
|
-
s.dependency 'SDWebImage', '>= 5.21.
|
|
26
|
+
# and maxDiskAge counting from an image's last use 5.20, and 5.21.4 and 5.21.5
|
|
27
|
+
# fix crashes on iOS 26 (SDWebImage #3849 and #3842).
|
|
28
|
+
s.dependency 'SDWebImage', '>= 5.21.5', '< 6.0'
|
|
29
29
|
s.dependency 'SDWebImageWebPCoder', '>= 0.8.4', '< 1.0'
|
|
30
30
|
# SVG images. From 1.7, as expo-image's, so apps with it share one copy.
|
|
31
31
|
s.dependency 'SDWebImageSVGCoder', '>= 1.7.0', '< 2.0'
|
|
@@ -67,16 +67,16 @@ final class FastImageEvents {
|
|
|
67
67
|
// onResourceReady and onLoadFailed, and EventDispatcher calls its listeners
|
|
68
68
|
// inline. Reanimated's listener flushes pending mount items, which can
|
|
69
69
|
// drop this view, and the drop clears the request inside its own
|
|
70
|
-
// callback, which Glide doesn't allow (it throws).
|
|
71
|
-
//
|
|
70
|
+
// callback, which Glide doesn't allow (it throws). Every event goes through
|
|
71
|
+
// here, so they keep their order: e.g. a view's onProgress comes after its
|
|
72
|
+
// onLoadStart, even from progress the UI thread had waiting before the
|
|
73
|
+
// load started.
|
|
72
74
|
static void send(FastImageViewWithUrl view, String name, WritableMap data) {
|
|
73
75
|
if (!view.handles(bit(name))) return;
|
|
74
76
|
MAIN.post(() -> dispatch(view, name, data));
|
|
75
77
|
}
|
|
76
78
|
|
|
77
|
-
|
|
78
|
-
// callbacks (e.g. progress, which is posted already).
|
|
79
|
-
static void dispatch(FastImageViewWithUrl view, String name, WritableMap data) {
|
|
79
|
+
private static void dispatch(FastImageViewWithUrl view, String name, WritableMap data) {
|
|
80
80
|
if (!view.handles(bit(name))) return;
|
|
81
81
|
ReactContext context = FastImageViewManager.getReactContext(view.getContext());
|
|
82
82
|
if (context == null) return;
|
|
@@ -9,7 +9,6 @@ import android.content.Context;
|
|
|
9
9
|
import android.content.ContextWrapper;
|
|
10
10
|
import android.graphics.Bitmap;
|
|
11
11
|
import android.graphics.PorterDuff;
|
|
12
|
-
import android.util.Log;
|
|
13
12
|
import android.graphics.Rect;
|
|
14
13
|
import android.graphics.drawable.BitmapDrawable;
|
|
15
14
|
import android.util.DisplayMetrics;
|
|
@@ -64,7 +63,6 @@ class FastImageViewManager extends SimpleViewManager<FastImageViewWithUrl>
|
|
|
64
63
|
static final String REACT_CLASS = "FastImageView";
|
|
65
64
|
static final String REACT_ON_LOAD_START_EVENT = "onFastImageLoadStart";
|
|
66
65
|
static final String REACT_ON_PROGRESS_EVENT = "onFastImageProgress";
|
|
67
|
-
static final String LOG_TAG = "FastImage";
|
|
68
66
|
// Download progress, by the key downloads are shared by
|
|
69
67
|
// (FastImageSharedDownloads.key): the views that get it, those with an onProgress from
|
|
70
68
|
// their load's onLoadStart to its onLoad or onError, and the latest step a
|
|
@@ -82,7 +80,7 @@ class FastImageViewManager extends SimpleViewManager<FastImageViewWithUrl>
|
|
|
82
80
|
private static final class Progress {
|
|
83
81
|
final Set<FastImageViewWithUrl> views = new LinkedHashSet<>();
|
|
84
82
|
// A step waits to be sent: later ones replace it meanwhile, so a url
|
|
85
|
-
// has at most one
|
|
83
|
+
// has at most one step waiting at a time.
|
|
86
84
|
boolean posted;
|
|
87
85
|
long loaded;
|
|
88
86
|
long total;
|
|
@@ -504,10 +502,12 @@ class FastImageViewManager extends SimpleViewManager<FastImageViewWithUrl>
|
|
|
504
502
|
|
|
505
503
|
// A download's progress (FastImageSharedDownloads), on its thread, which
|
|
506
504
|
// only notes it if a view wants it (so downloads of images without an
|
|
507
|
-
// onProgress post nothing).
|
|
508
|
-
//
|
|
509
|
-
//
|
|
510
|
-
//
|
|
505
|
+
// onProgress post nothing). The UI thread, where views start and end their
|
|
506
|
+
// loads, picks the views that take it, and posts it behind their other
|
|
507
|
+
// events (FastImageEvents.send): a view only gets it during its own load,
|
|
508
|
+
// after its onLoadStart, not after its onLoad or once it loads again, and
|
|
509
|
+
// progress posted during a download comes before the onLoad Glide posts
|
|
510
|
+
// after it.
|
|
511
511
|
static void onDownloadProgress(final String key, long loaded, long total) {
|
|
512
512
|
synchronized (PROGRESS) {
|
|
513
513
|
Progress progress = PROGRESS.get(key);
|
|
@@ -554,14 +554,8 @@ class FastImageViewManager extends SimpleViewManager<FastImageViewWithUrl>
|
|
|
554
554
|
event.putInt("total", (int) total);
|
|
555
555
|
// Downloads only report a known length (see FastImageSharedDownloads).
|
|
556
556
|
event.putDouble("progress", Math.min(1.0, Math.max(0.0, (double) loaded / total)));
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
} catch (RuntimeException e) {
|
|
560
|
-
// E.g. the view's React instance is gone: progress isn't worth
|
|
561
|
-
// crashing the app for.
|
|
562
|
-
// (Not the key: it has the request's headers.)
|
|
563
|
-
Log.w(LOG_TAG, "Couldn't send onProgress", e);
|
|
564
|
-
}
|
|
557
|
+
// Posted after the view's onLoadStart, which may still be waiting.
|
|
558
|
+
FastImageEvents.send(view, REACT_ON_PROGRESS_EVENT, event);
|
|
565
559
|
}
|
|
566
560
|
}
|
|
567
561
|
|