Commit Graph

1949 Commits

Author SHA1 Message Date
DreamPiggy 08ca5f4b22 Try to fix the SDDisplayLink danger pointer because of unsafe_unretained for self from the CVDisplayLinkRef
Using the same solution from iOS/watchOS via SDWeakProxy
2023-05-10 16:00:00 +08:00
DreamPiggy 507f1b6b45 Using lock to ensure SDImageFramePool register/unregister logic in multi-thread environment 2023-05-09 16:50:41 +08:00
DreamPiggy 181f8d2183 Fix the issue that per-provider frame pool does not get dealloced 2023-05-09 16:50:41 +08:00
DreamPiggy ef69460dc7 Fix the test case test26AnimatedImageStopAnimatingClearBuffer 2023-05-09 16:50:41 +08:00
DreamPiggy 858b64aef7 Try to optimize the time when calculate the maxBufferCount, it's cheap to get free memory so we check each time before prefetch
Also, move the memory warning handler into frame pool class (100 player may use one frame pool)
2023-05-09 16:50:41 +08:00
DreamPiggy a206229905 Introduce frame pool for SDAnimatedImage playback. Solve when multiple image view references the same URL image cause un-wanted decode which waste RAM/CPU 2023-05-09 16:50:41 +08:00
DreamPiggy 09f0fdd189
Merge pull request #3526 from dreampiggy/bugfix/try_avoid_inline_sdcallback_queue
Try to solve the strange dispatch group crash in SDSafeExecute by removing inline
2023-05-06 15:55:18 +08:00
DreamPiggy ada908a853 Extended gcd queue to avoid SDCallbackQueue dealloc while during dispatch 2023-05-05 18:51:12 +08:00
DreamPiggy 17b5a1d9ab Check queue equality only when queue specific is available 2023-05-05 18:46:37 +08:00
DreamPiggy 4ffd068762 Try to solve the strange dispatch group crash in SDSafeExecute by removing inline
Guessing the queue ARC lifecycle is wrong during some of compiler optimization
2023-05-05 18:41:20 +08:00
DreamPiggy 71bcdf006a Performance: Opt when multiple same URL query in parallels, which may cause duplicated decode and store disk operation 2023-04-25 18:25:05 +08:00
DreamPiggy 4cee95d5a2 Revert the SDDisplayLink for watchOS, fix the animated image duration bug 2023-04-21 18:53:36 +08:00
DreamPiggy a549e99922
Merge pull request #3519 from dreampiggy/bugfix/warning_c_no_param
Fix the warning of C function with no param
2023-04-21 15:54:19 +08:00
DreamPiggy ec278a2fb5 Fix the warning of C function with no param 2023-04-21 15:52:41 +08:00
Tim Johnsen c79416bc2e Ensure directory exists on init instead of on each save. 2023-04-18 16:29:24 -07:00
Tim Johnsen 3fd19c16eb Disable iCloud backup once per directory creation instead of for each image save. 2023-04-18 16:27:30 -07:00
DreamPiggy e0b7cc5241 Fix the blur effect logic by avoid color convert and always use three box-blur methodology 2023-03-03 22:57:14 +08:00
DreamPiggy 8d09564f27 Protect the disk operation when input key is nil 2023-03-03 15:10:42 +08:00
DreamPiggy 5bb64eae39 Fix the wrong declaration of SDCallbackQueue's block, should be escaping to match GCD block
This may cause the wrong lifecycle for block (earily release)
2023-02-21 19:12:12 +08:00
DreamPiggy 748def0a0c
Merge pull request #3496 from dreampiggy/temp/try_fix_promotion
Try to fix the SDAnimatedImageView playback speed issue in Promotion devices (iPhone Pro)
2023-02-18 19:36:15 +08:00
DreamPiggy 856ecd6235 Fix leak of display mode 2023-02-18 18:07:31 +08:00
DreamPiggy 3440b7c0fb Update test case for display link and revert the protect code 2023-02-18 18:04:01 +08:00
DreamPiggy b25864cc71 Fix the issue when multiple request for same url failed, the completedBlock will callback more times 2023-02-18 17:27:13 +08:00
DreamPiggy 271e8d8b12 Try to fix display link callback duration calculation issue, using next timestamp for iOS 10+ / watchOS, previous timestamp for iOS 9 2023-02-12 03:02:07 +08:00
DreamPiggy f2d7610181 Change Objc BOOL true/false into correct YES/NO 2023-02-07 02:32:11 +08:00
DreamPiggy 7cec27bab9 Fix the atomic logic between downloader and operation again
Remove the wrong logic to modify queue priority when re-use operation
2023-02-07 02:31:18 +08:00
DreamPiggy eecc7e4380
Merge pull request #3480 from dreampiggy/bugfix/data_copy_crash
Remove the unused extra copy for `SDAnimatedImage` data initializer
2023-02-06 21:50:28 +08:00
DreamPiggy fbe8880ab7 Remove the unused extra copy for `SDAnimatedImage` data initializer 2023-02-06 21:11:59 +08:00
DreamPiggy 02969011b0 Try to fix the SDAsyncBlockOperation's race condition
Use the correct way for subclassing NSOperation
2023-02-06 21:05:51 +08:00
DreamPiggy a052164350
Merge pull request #3477 from dreampiggy/bugfix/ensure_downloader_callback_atomic
Ensure the Downloader and DownloaderOperation callback the completion in atomic and never miss one
2023-02-06 20:41:10 +08:00
DreamPiggy b6910be155 Added test case `test31ThatMultipleRequestForSameURLNeverSkipCallback` to ensure all download request for same url always callback 2023-02-06 18:52:46 +08:00
DreamPiggy 0c94e540bc Revert back the NSOperationQueue, seems has better performance on this cases (may dispatch multiple block but not important, one finished is OK) 2023-02-06 16:09:07 +08:00
DreamPiggy 6e1fee7834 Try not introduce new public API for operation, attach the `isCompleted` property using associated object from downloader, ensure compatibility 2023-02-06 15:06:54 +08:00
DreamPiggy 43b94130c7 Ensure the DownloaderOperation callback the completion in atomic and never miss one
The downloader will now check and ignore a `transferedDataFinished` operation (which is callbacking its own completion), because it's not safe in multi-thread environment, create new network request instead
2023-02-03 19:02:07 +08:00
DreamPiggy f25cc6bb1c
Merge pull request #3474 from dreampiggy/bugfix/atomic_fix
Avoid compiler generate the wrong property attribute with non-atomic
2023-01-22 14:12:35 +08:00
DreamPiggy a66ff8e5c9 Avoid compiler generate the wrong property attribute with non-atomic 2023-01-22 11:45:19 +08:00
DreamPiggy a80af99d0a Fix the issue the fallback logic of ImageIO Source should avoid passing any UTI hint 2023-01-22 11:23:18 +08:00
DreamPiggy 975502b4a6
Merge pull request #3469 from dreampiggy/feat/animated_image_encode
Added encodeWithFrames API for animation encoding in custom coder, better for usage
2023-01-17 16:50:50 +08:00
DreamPiggy a01715e196
Merge pull request #3468 from dreampiggy/feat/decode_solution_change
Update the decode solution to allows CoreGraphics avoid using any UIKit method
2023-01-17 16:20:07 +08:00
DreamPiggy 0bdb7865c7 Change the immutable frames array 2023-01-17 16:18:17 +08:00
DreamPiggy 985c84be75 Opt the macOS legacy animated encode, with the weak assigned frames to avoid re-decode again
It's still recommended to use the new API
2023-01-17 16:16:09 +08:00
DreamPiggy 8ec3bc83d7 Added encodeWithFrames API for animation encoding in custom coder, better for usage
The exist API need wrap the frames into a new image and extract, consume RAM and CPU
2023-01-17 15:28:26 +08:00
DreamPiggy c0f7023472 Update the decode solution to allows CoreGraphics avoid using any UIKit method
This is back compatible to old version's RAM behavior
2023-01-17 15:27:36 +08:00
DreamPiggy e083ab293f Fix the wrong behavior after 5.15.0 cache changes 2023-01-12 14:49:02 +08:00
DreamPiggy 08ec6cf253 Adjustment for manager && cache call, add deprecation 2023-01-11 16:00:16 +08:00
DreamPiggy 246cfa935d Change the cache's encoding in global queue to avoid block ioQueue for IO read/write, performance related 2023-01-11 15:32:04 +08:00
DreamPiggy d93a08fc91 Added `SDWebImageContextImageEncodeOptions` to pass encode options like compression quality to SDImageCache storeImage API 2023-01-11 15:08:31 +08:00
DreamPiggy 720a0974d4 Fix SwiftPM issue 2023-01-10 12:49:20 +08:00
DreamPiggy e1e0841102 Rename the internal property to avoid misleading 2023-01-09 22:08:48 +08:00
DreamPiggy 007100d18f Supports the old store cache API without context, which does not supports callback queue customization 2023-01-09 22:08:48 +08:00
DreamPiggy 1b086711ae Fix the issue because of main queue label hack 2023-01-09 22:08:48 +08:00
DreamPiggy 43d74211c3 Added test case `testSDCallbackQueue` 2023-01-09 22:08:48 +08:00
DreamPiggy 90eeb4d830 Deprecate SDWebImagePrefetcher.delegateQueue, translate to use context[SDWebImageContextCallbackQueue] instead 2023-01-09 18:06:14 +08:00
DreamPiggy 5a4b4cf16d Change the asyncSafe to the queue level configuration, introduce SDCallbackPolicy 2023-01-09 18:06:14 +08:00
DreamPiggy 67520b9f55 Fix the new added storeCache API which passing callbackQueue 2023-01-06 19:49:35 +08:00
DreamPiggy fdd9a98210 Do not check nil block, useless in our use case 2023-01-06 19:36:03 +08:00
DreamPiggy 57403c9d3f Rename to use `dispatch_block_t` alias 2023-01-06 19:09:39 +08:00
DreamPiggy b5d712a378 Implements the Callback queue dispatch
Fix some missing components
2023-01-06 18:52:31 +08:00
DreamPiggy 43ec4726e1 Added context option `callbackQueue` for advanced user to control which queue to callback
This is used for user who call SDWebImage outside from main queue and need precise queue control, such as avoid chain queue blocking (like AVKit lazy load)
2023-01-04 18:47:50 +08:00
DreamPiggy 8be9f2c3f9
Merge pull request #3461 from dreampiggy/bugfix/yuv420_jpeg_hevc
Fix the iOS 15+ force-decode hack break Apple's HEIF and JPEG YUV420 optimization
2022-12-27 19:57:48 +08:00
DreamPiggy d2221403e1 Removed the unused options for CGImageSourceCopyPropertiesAtIndex 2022-12-27 19:55:12 +08:00
DreamPiggy a99c0de68d Fix the iOS 15+ force-decode hack break Apple's HEIF and JPEG YUV420 optimization
The lazyDecode logic effect the static image as well. Should roll back and only check for animated image
2022-12-27 18:58:21 +08:00
DreamPiggy c60e6714dd Added `ioQueueAttributes` to use concurrent or control QoS for image cache internal IO Queue 2022-12-27 17:24:07 +08:00
DreamPiggy 0274aa85fe
Merge pull request #3452 from kinarobin/fetch-frame-early-for-animated-image-render
[Performance]when frame timestamp not reached, we should prefetch frame in advance for image render.
2022-12-27 16:51:54 +08:00
DreamPiggy 717461459f Hack the first frame to ensure it always displayed in first screen refresh 2022-12-26 19:05:39 +08:00
DreamPiggy b5db7fac68 The poster image should not trigger a frameChange callback 2022-12-26 18:53:55 +08:00
kinarobin a15f594869 prefetch image in advance 2022-12-02 21:24:36 +08:00
DreamPiggy 9c0c715d6a Move the SD_CHECK_CGIMAGE_RETAIN_SOURCE assertion to SDWebImage Demo and Tests only
This does not effects user who use this framework, only useful for ourselves to ensure Apple does not break our code
2022-11-14 17:07:29 +08:00
DreamPiggy 736f3f41f7 Move block before sending to the main queue
This can avoid some life cycle issue and increase performance
2022-11-11 14:29:20 +08:00
DreamPiggy 384b2d7c8b Fix the missing lock for callbackTokens which may cause thread-safe issue 2022-11-11 14:22:49 +08:00
DreamPiggy 30f165abd5 Change from instance method to class method 2022-11-11 00:07:32 +08:00
DreamPiggy f4706453d6 Use CoreGraphics to decode PDF instead of ImageIO to solve iOS 16's issue
We no longer use ImageIO to decode PDF, seems they don't maintain that kSDCGImageSourceRasterizationDPI
Copy the code from SDWebImagePDFCoder, need to update
2022-11-10 23:54:14 +08:00
DreamPiggy d96ea392d1 Fix the iOS 12 crash because the underlyingQueue is nil
Use NSOperation dependency to solve this issue
2022-11-10 22:03:12 +08:00
DreamPiggy bfa91a291b Added the helper convenient API `sd_isThumbnail`
Fix the metadata does not saved
2022-11-08 22:40:36 +08:00
DreamPiggy 03b46475eb Revert #2792, the autoreleasepool does not solve the issue 2022-11-08 21:49:26 +08:00
DreamPiggy 6ce59aa8c1
Merge pull request #3429 from dreampiggy/perf/remove_conforms_to_protocol
Replace conformsToProtocol call with appropriate respondsToSelector check to improve performance
2022-11-08 21:44:07 +08:00
DreamPiggy 7ddf3214e6 Fix the test case again on below iOS 15 2022-11-08 21:18:20 +08:00
DreamPiggy 9aa27b61e8 Replace conformsToProtocol call with appropriate respondsToSelector check
This effect API called with multiple times, for some one-time setup and important check, the conformsToProtocol is remained
2022-11-08 20:04:15 +08:00
DreamPiggy 359036eae9
Merge pull request #3428 from dreampiggy/opt/avoid_store_again_when_origin_disk_exits
Avoid store again when origin disk cache hit during Thumbnail or Transformer with smaller pixel size
2022-11-08 19:16:05 +08:00
riv1r 9599a78ff9
Fix del redundant autoreleasepool (#3388)
* fix:del redundant autoreleasepool, because frameProperties is not a __autoreleasing reference object, for-Loop does not cause untimely release

* fix:del redundant autoreleasepool, because frame is strongly referenced by frames, for-Loop does not cause untimely release

* fix:del redundant autoreleasepool, because sourceTileImageRef is released by CGImageRelease, for-Loop does not cause untimely release

Co-authored-by: chendongran06039 <chendongran06039@hellobike.com>
Co-authored-by: DreamPiggy <lizhuoli1126@126.com>
2022-11-08 17:29:49 +08:00
DreamPiggy f93cf96832 Avoid store original disk cache again when using thumbnail or transformer from the full size data
This solve #3395
2022-11-08 16:44:40 +08:00
DreamPiggy 0d1c603d50 Add the possible nullable logic check when the force-decode/copy failed 2022-11-08 16:19:49 +08:00
DreamPiggy c81aec4ccd Ignore the dynamic UTI type hint to avoid extra log 2022-11-08 16:15:25 +08:00
DreamPiggy 136d05fce8 Add extra check when user provide SDImageCoderDecodeUseLazyDecoding 2022-11-07 12:44:46 +08:00
DreamPiggy 3000dd5098 Fix the `sd_isDecoded` did not set after we use SDCGImageCreateCopy 2022-11-07 12:20:04 +08:00
DreamPiggy db25af9506 Recovery the assert check on only iPhone/TV simulator in debug mode 2022-11-07 12:10:22 +08:00
DreamPiggy abc06f020a Added `SDImageCoderDecodeUseLazyDecoding` to control whether to use lazy-decoding for ImageIO or not
Defaults to NO for animated image coder but YES for static image coder to match current behavior
This also use another way to solve iOS 15+'s CGImageGetImageSource issue
2022-11-07 12:10:22 +08:00
DreamPiggy 279f636ac5 Minor check the logic that UTI has high priority than path extension 2022-10-31 23:52:32 +08:00
DreamPiggy e3c6cfa066 Update test case to make clear that transformed image and thumbnailed image will callback without data 2022-10-31 23:52:32 +08:00
DreamPiggy 2fd75638fe Refactor the hack for multiple thumbnail image request at the same time
1. Put the hack logic into SDWebImageDownloadOperation, each different thumbnail image request will have its callback with desired size of image using different decoding call.
2. Progressive Thumbnail decoding (use together) does not have this behavior, because I think progressive thumbnail is really rare and tolerant, people just use the first thumbnail size image for preview and OK.
3. The manager logic refactor with separate steps, focus on clear to understand the complicated logic and maintainess
4. The thumbnail decode/transformed will callback valid image, but with nil data, this matches the behavior as wiki pages.
2022-10-31 23:52:32 +08:00
DreamPiggy 2f3652dc2e Feature: Introduce SDWebImageContextImageDecodeOptions, deprecate SDImageCoderWebImageContext
This can solve the retain cycle from the scratch, instead of hacking
2022-10-29 20:51:11 +08:00
DreamPiggy b014808ddd Merge branch '5.13.x' of github.com:SDWebImage/SDWebImage
# Conflicts:
#	SDWebImage/Core/SDImageCacheDefine.m
2022-10-29 20:40:00 +08:00
DreamPiggy 318cca556b Fix the issue that progressive decode logic does not get updated 2022-10-29 20:34:04 +08:00
DreamPiggy b46fe38c72 Quick fix the issue that UIImage.sd_decodeOptions cause retain cycle when pass custom cache in context option
Now the SDImageCoderWebImageContext does not pass the built-in options, only custom options will be passed, and deprecated in 5.14.0
2022-10-29 19:50:45 +08:00
DreamPiggy 8dd6e25cd8 Added NEF test case, as well as BMP type enum
The file extension hint works on iOS/macOS for current
2022-10-29 18:13:36 +08:00
DreamPiggy b1b16a17b3 Support use url.path or custom UTI hint passed to ImageIO, solve the TIFF/NEF/SRW raw image decoding with wrong size
This is because file extension will cause ImageIO use different codec, which does not support all of them without context
2022-10-27 11:11:28 +08:00
DreamPiggy 9b2ddc9ea8 [NFC] A little optimization for MutableArray creation 2022-09-26 17:38:37 +08:00
DreamPiggy 347cf1d1cc Fix the potential out of bounds crash for ImageIO incremental animation decoding (like GIF)
This patch from the SDWebImageWebPCoder/pull/68
2022-09-26 17:32:25 +08:00
DreamPiggy ea9f573744 Remove the temp assert code (for debugging usage) 2022-09-19 18:30:13 +08:00
DreamPiggy 89178a7d89 Update to force decode CGImage before any UIImage initialization on iOS 15+ 2022-09-19 18:30:13 +08:00