appium-webdriveragent 9.0.5 → 9.0.6

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/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## [9.0.6](https://github.com/appium/WebDriverAgent/compare/v9.0.5...v9.0.6) (2025-02-28)
2
+
3
+ ### Bug Fixes
4
+
5
+ * optimize LRU cache ([#985](https://github.com/appium/WebDriverAgent/issues/985)) ([46dc417](https://github.com/appium/WebDriverAgent/commit/46dc417da9f4a843838b414c0b154d6f478dbc0b))
6
+
1
7
  ## [9.0.5](https://github.com/appium/WebDriverAgent/compare/v9.0.4...v9.0.5) (2025-02-26)
2
8
 
3
9
  ### Bug Fixes
@@ -15,11 +15,11 @@
15
15
  <key>CFBundlePackageType</key>
16
16
  <string>FMWK</string>
17
17
  <key>CFBundleShortVersionString</key>
18
- <string>9.0.5</string>
18
+ <string>9.0.6</string>
19
19
  <key>CFBundleSignature</key>
20
20
  <string>????</string>
21
21
  <key>CFBundleVersion</key>
22
- <string>9.0.5</string>
22
+ <string>9.0.6</string>
23
23
  <key>NSPrincipalClass</key>
24
24
  <string/>
25
25
  </dict>
@@ -73,7 +73,17 @@ const int ELEMENT_CACHE_SIZE = 1024;
73
73
  @throw [NSException exceptionWithName:FBStaleElementException reason:reason userInfo:@{}];
74
74
  }
75
75
  if (checkStaleness) {
76
- [element fb_takeSnapshot:NO];
76
+ @try {
77
+ [element fb_takeSnapshot:NO];
78
+ } @catch (NSException *exception) {
79
+ // if the snapshot method threw FBStaleElementException (implying the element is stale) we need to explicitly remove it from the cache, PR: https://github.com/appium/WebDriverAgent/pull/985
80
+ if ([exception.name isEqualToString:FBStaleElementException]) {
81
+ @synchronized (self.elementCache) {
82
+ [self.elementCache removeObjectForKey:uuid];
83
+ }
84
+ }
85
+ @throw exception;
86
+ }
77
87
  }
78
88
  return element;
79
89
  }
@@ -54,6 +54,13 @@ NS_ASSUME_NONNULL_BEGIN
54
54
  */
55
55
  - (NSArray *)allObjects;
56
56
 
57
+ /**
58
+ Removes the object associated with the specified key from the cache.
59
+
60
+ @param key The key identifying the object to remove.
61
+ */
62
+ - (void)removeObjectForKey:(id<NSCopying>)key;
63
+
57
64
  @end
58
65
 
59
66
  NS_ASSUME_NONNULL_END
@@ -135,4 +135,12 @@
135
135
  }
136
136
  }
137
137
 
138
+ - (void)removeObjectForKey:(id<NSCopying>)key
139
+ {
140
+ LRUCacheNode *node = self.store[key];
141
+ if (node != nil) {
142
+ [self removeNode:node];
143
+ }
144
+ }
145
+
138
146
  @end
@@ -96,4 +96,33 @@
96
96
  XCTAssertEqualObjects(@[@(count)], cache.allObjects);
97
97
  }
98
98
 
99
+ - (void)testRemoveExistingObjectForKey {
100
+ LRUCache *cache = [[LRUCache alloc] initWithCapacity:3];
101
+ [cache setObject:@"foo" forKey:@"bar"];
102
+ [cache setObject:@"foo2" forKey:@"bar2"];
103
+ [cache setObject:@"foo3" forKey:@"bar3"];
104
+ [self assertArray:@[@"foo3", @"foo2", @"foo"] equalsTo:cache.allObjects];
105
+ [cache removeObjectForKey:@"bar2"];
106
+ XCTAssertNil([cache objectForKey:@"bar2"]);
107
+ [self assertArray:@[@"foo3", @"foo"] equalsTo:cache.allObjects];
108
+ }
109
+
110
+ - (void)testRemoveNonExistingObjectForKey {
111
+ LRUCache *cache = [[LRUCache alloc] initWithCapacity:2];
112
+ [cache setObject:@"foo" forKey:@"bar"];
113
+ [cache removeObjectForKey:@"nonExisting"];
114
+ XCTAssertNotNil([cache objectForKey:@"bar"]);
115
+ [self assertArray:@[@"foo"] equalsTo:cache.allObjects];
116
+ }
117
+
118
+ - (void)testRemoveAndInsertFlow {
119
+ LRUCache *cache = [[LRUCache alloc] initWithCapacity:2];
120
+ [cache setObject:@"foo" forKey:@"bar"];
121
+ [cache setObject:@"foo2" forKey:@"bar2"];
122
+ [cache removeObjectForKey:@"bar"];
123
+ XCTAssertNil([cache objectForKey:@"bar"]);
124
+ [cache setObject:@"foo3" forKey:@"bar3"];
125
+ [self assertArray:@[@"foo3", @"foo2"] equalsTo:cache.allObjects];
126
+ }
127
+
99
128
  @end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "appium-webdriveragent",
3
- "version": "9.0.5",
3
+ "version": "9.0.6",
4
4
  "description": "Package bundling WebDriverAgent",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",