Skip to content

Commit 116a91f

Browse files
committed
fix: add enabledMemoryCache option to SVGAParser, disable memory cache to default.
fix: use SSZipArchiver 2.1.4
1 parent 165b4ca commit 116a91f

9 files changed

Lines changed: 51 additions & 17 deletions

File tree

Podfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ platform :ios, '8.0'
22

33
target 'SVGAPlayer' do
44

5-
pod 'SSZipArchive', '~> 1.8.1'
5+
pod 'SSZipArchive', '~> 2.1.4'
66
pod 'Protobuf', '~> 3.4'
77

88
end
99

1010
target 'SVGAPlayer React' do
1111

12-
pod 'SSZipArchive', '~> 1.8.1'
12+
pod 'SSZipArchive', '~> 2.1.4'
1313
pod 'React', :podspec => 'https://raw.githubusercontent.com/yyued/react-native-runtime-ios/0.45.1/React.podspec', :subspecs => [
1414
'Core',
1515
'ART',

Podfile.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ PODS:
2727
- React/Core
2828
- React/RCTWebSocket (0.45.1):
2929
- React/Core
30-
- SSZipArchive (1.8.1)
30+
- SSZipArchive (2.1.4)
3131
- Yoga (1.9.0)
3232

3333
DEPENDENCIES:
@@ -43,7 +43,7 @@ DEPENDENCIES:
4343
- React/RCTText (from `https://raw.githubusercontent.com/yyued/react-native-runtime-ios/0.45.1/React.podspec`)
4444
- React/RCTVibration (from `https://raw.githubusercontent.com/yyued/react-native-runtime-ios/0.45.1/React.podspec`)
4545
- React/RCTWebSocket (from `https://raw.githubusercontent.com/yyued/react-native-runtime-ios/0.45.1/React.podspec`)
46-
- SSZipArchive (~> 1.8.1)
46+
- SSZipArchive (~> 2.1.4)
4747
- Yoga
4848

4949
SPEC REPOS:
@@ -59,9 +59,9 @@ EXTERNAL SOURCES:
5959
SPEC CHECKSUMS:
6060
Protobuf: 1eb9700044745f00181c136ef21b8ff3ad5a0fd5
6161
React: 505e0132cd9aaba1a56e47ef509220dd794ec9be
62-
SSZipArchive: 04547dfa448be5ed7ecbaf7eaf8a6e9eb9b42997
62+
SSZipArchive: 41455d4b8d2b6ab93990820b50dc697c2554a322
6363
Yoga: aaae8abea68951f60bee05f6277d3eed90bb91bb
6464

65-
PODFILE CHECKSUM: b7d71960f4fe0b08fd7d4651b412bb8bec6c19f2
65+
PODFILE CHECKSUM: 7f6714245d47e69d2933463289e4c4d6de65b831
6666

67-
COCOAPODS: 1.5.3
67+
COCOAPODS: 1.6.0.beta.2

SVGAPlayer-React.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Pod::Spec.new do |s|
33
s.name = "SVGAPlayer"
4-
s.version = "2.3.0"
4+
s.version = "2.3.1"
55
s.summary = "SVGAPlayer 是一个高性能的动画播放器"
66
s.description = <<-DESC
77
SVGA 是一个私有的动画格式,由 YY UED 主导开发。
@@ -16,7 +16,7 @@ Pod::Spec.new do |s|
1616
s.subspec 'Core' do |ss|
1717
ss.source_files = "Source/*.{h,m}", "React/*.{h,m}"
1818
ss.requires_arc = true
19-
ss.dependency 'SSZipArchive', '1.8.1'
19+
ss.dependency 'SSZipArchive', '2.1.4'
2020
ss.library = "z"
2121
ss.dependency 'SVGAPlayer/ProtoFiles'
2222
end

SVGAPlayer.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Pod::Spec.new do |s|
33
s.name = "SVGAPlayer"
4-
s.version = "2.3.0"
4+
s.version = "2.3.1"
55
s.summary = "SVGAPlayer 是一个高性能的动画播放器"
66
s.description = <<-DESC
77
SVGA 是一个私有的动画格式,由 YY UED 主导开发。
@@ -17,7 +17,7 @@ Pod::Spec.new do |s|
1717
s.subspec 'Core' do |ss|
1818
ss.source_files = "Source/*.{h,m}"
1919
ss.requires_arc = true
20-
ss.dependency 'SSZipArchive', '1.8.1'
20+
ss.dependency 'SSZipArchive', '2.1.4'
2121
ss.library = "z"
2222
ss.framework = "AVFoundation"
2323
ss.dependency 'SVGAPlayer/ProtoFiles'
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>SchemeUserState</key>
6+
<dict>
7+
<key>SVGAPlayer React.xcscheme</key>
8+
<dict>
9+
<key>orderHint</key>
10+
<integer>7</integer>
11+
</dict>
12+
<key>SVGAPlayer.xcscheme</key>
13+
<dict>
14+
<key>orderHint</key>
15+
<integer>6</integer>
16+
</dict>
17+
</dict>
18+
</dict>
19+
</plist>
Binary file not shown.

Source/SVGAParser.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
@interface SVGAParser : NSObject
1414

15+
@property (nonatomic, assign) BOOL enabledMemoryCache;
16+
1517
- (void)parseWithURL:(nonnull NSURL *)URL
1618
completionBlock:(void ( ^ _Nonnull )(SVGAVideoEntity * _Nullable videoItem))completionBlock
1719
failureBlock:(void ( ^ _Nullable)(NSError * _Nullable error))failureBlock;

Source/SVGAParser.m

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ - (void)parseWithCacheKey:(nonnull NSString *)cacheKey
124124
[videoItem resetImagesWithProtoObject:protoObject];
125125
[videoItem resetSpritesWithProtoObject:protoObject];
126126
[videoItem resetAudiosWithProtoObject:protoObject];
127-
[videoItem saveCache:cacheKey];
127+
if (self.enabledMemoryCache) {
128+
[videoItem saveCache:cacheKey];
129+
}
128130
if (completionBlock) {
129131
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
130132
completionBlock(videoItem);
@@ -148,7 +150,9 @@ - (void)parseWithCacheKey:(nonnull NSString *)cacheKey
148150
SVGAVideoEntity *videoItem = [[SVGAVideoEntity alloc] initWithJSONObject:JSONObject cacheDir:cacheDir];
149151
[videoItem resetImagesWithJSONObject:JSONObject];
150152
[videoItem resetSpritesWithJSONObject:JSONObject];
151-
[videoItem saveCache:cacheKey];
153+
if (self.enabledMemoryCache) {
154+
[videoItem saveCache:cacheKey];
155+
}
152156
if (completionBlock) {
153157
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
154158
completionBlock(videoItem);
@@ -200,7 +204,9 @@ - (void)parseWithData:(nonnull NSData *)data
200204
[videoItem resetImagesWithProtoObject:protoObject];
201205
[videoItem resetSpritesWithProtoObject:protoObject];
202206
[videoItem resetAudiosWithProtoObject:protoObject];
203-
[videoItem saveCache:cacheKey];
207+
if (self.enabledMemoryCache) {
208+
[videoItem saveCache:cacheKey];
209+
}
204210
if (completionBlock) {
205211
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
206212
completionBlock(videoItem);
@@ -253,7 +259,9 @@ - (void)parseWithData:(nonnull NSData *)data
253259
SVGAVideoEntity *videoItem = [[SVGAVideoEntity alloc] initWithProtoObject:protoObject cacheDir:cacheDir];
254260
[videoItem resetImagesWithProtoObject:protoObject];
255261
[videoItem resetSpritesWithProtoObject:protoObject];
256-
[videoItem saveCache:cacheKey];
262+
if (self.enabledMemoryCache) {
263+
[videoItem saveCache:cacheKey];
264+
}
257265
if (completionBlock) {
258266
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
259267
completionBlock(videoItem);
@@ -277,7 +285,9 @@ - (void)parseWithData:(nonnull NSData *)data
277285
SVGAVideoEntity *videoItem = [[SVGAVideoEntity alloc] initWithJSONObject:JSONObject cacheDir:cacheDir];
278286
[videoItem resetImagesWithJSONObject:JSONObject];
279287
[videoItem resetSpritesWithJSONObject:JSONObject];
280-
[videoItem saveCache:cacheKey];
288+
if (self.enabledMemoryCache) {
289+
[videoItem saveCache:cacheKey];
290+
}
281291
if (completionBlock) {
282292
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
283293
completionBlock(videoItem);

Source/SVGAVectorLayer.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ - (void)stepToFrame:(NSInteger)frame {
5555
}
5656

5757
- (BOOL)isKeepFrame:(SVGAVideoSpriteFrameEntity *)frameItem {
58-
if ([frameItem.shapes.firstObject isKindOfClass:[NSDictionary class]]) {
58+
if (frameItem.shapes.count == 0) {
59+
return NO;
60+
}
61+
else if ([frameItem.shapes.firstObject isKindOfClass:[NSDictionary class]]) {
5962
return [frameItem.shapes.firstObject[@"type"] isKindOfClass:[NSString class]] &&
6063
[frameItem.shapes.firstObject[@"type"] isEqualToString:@"keep"];
6164
}

0 commit comments

Comments
 (0)