appium-webdriveragent 17.0.7 → 17.0.8

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
@@ -3,6 +3,13 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [17.0.8](https://github.com/appium/appium-ios/compare/appium-webdriveragent@17.0.7...appium-webdriveragent@17.0.8) (2026-11-16)
7
+
8
+ ### Bug Fixes
9
+
10
+ * **webdriveragent:** clear screen recording state before attachment cleanup ([#115](https://github.com/appium/appium-ios/issues/115)) ([9caef7e](https://github.com/appium/appium-ios/commit/9caef7ee9a77541a785a5248576fd3266afae4a2))
11
+
12
+
6
13
  ## [17.0.7](https://github.com/appium/appium-ios/compare/appium-webdriveragent@17.0.6...appium-webdriveragent@17.0.7) (2026-11-16)
7
14
 
8
15
  ### Bug Fixes
@@ -69,10 +69,10 @@ const NSUInteger DEFAULT_CODEC = 0;
69
69
  NSDictionary *response = [FBScreenRecordingContainer.sharedInstance toDictionary];
70
70
  NSError *error;
71
71
  if (![FBXCTestDaemonsProxy stopScreenRecordingWithUUID:recordingId error:&error]) {
72
- [FBScreenRecordingContainer.sharedInstance reset];
72
+ [FBScreenRecordingContainer.sharedInstance resetIfPromiseIs:activeScreenRecording];
73
73
  return FBResponseWithUnknownError(error);
74
74
  }
75
- [FBScreenRecordingContainer.sharedInstance reset];
75
+ [FBScreenRecordingContainer.sharedInstance resetIfPromiseIs:activeScreenRecording];
76
76
  return FBResponseWithObject(response);
77
77
  }
78
78
 
@@ -15,11 +15,11 @@
15
15
  <key>CFBundlePackageType</key>
16
16
  <string>FMWK</string>
17
17
  <key>CFBundleShortVersionString</key>
18
- <string>17.0.7</string>
18
+ <string>17.0.8</string>
19
19
  <key>CFBundleSignature</key>
20
20
  <string>????</string>
21
21
  <key>CFBundleVersion</key>
22
- <string>17.0.7</string>
22
+ <string>17.0.8</string>
23
23
  <key>NSPrincipalClass</key>
24
24
  <string/>
25
25
  </dict>
@@ -9,19 +9,16 @@
9
9
 
10
10
  #import "FBScreenRecordingContainer.h"
11
11
 
12
+ #import "FBLogger.h"
12
13
  #import "FBScreenRecordingPromise.h"
13
14
 
14
- @interface FBScreenRecordingContainer ()
15
-
16
- @property (readwrite) NSUInteger fps;
17
- @property (readwrite) long long codec;
18
- @property (readwrite) FBScreenRecordingPromise* screenRecordingPromise;
19
- @property (readwrite) NSNumber *startedAt;
20
-
21
- @end
22
-
23
15
  @implementation FBScreenRecordingContainer
24
16
 
17
+ @synthesize fps = _fps;
18
+ @synthesize codec = _codec;
19
+ @synthesize screenRecordingPromise = _screenRecordingPromise;
20
+ @synthesize startedAt = _startedAt;
21
+
25
22
  + (instancetype)sharedInstance
26
23
  {
27
24
  static FBScreenRecordingContainer *instance;
@@ -32,57 +29,105 @@
32
29
  return instance;
33
30
  }
34
31
 
32
+ - (NSUInteger)fps
33
+ {
34
+ @synchronized (self) {
35
+ return _fps;
36
+ }
37
+ }
38
+
39
+ - (long long)codec
40
+ {
41
+ @synchronized (self) {
42
+ return _codec;
43
+ }
44
+ }
45
+
46
+ - (nullable FBScreenRecordingPromise *)screenRecordingPromise
47
+ {
48
+ @synchronized (self) {
49
+ return _screenRecordingPromise;
50
+ }
51
+ }
52
+
53
+ - (nullable NSNumber *)startedAt
54
+ {
55
+ @synchronized (self) {
56
+ return _startedAt;
57
+ }
58
+ }
59
+
35
60
  - (void)storeScreenRecordingPromise:(FBScreenRecordingPromise *)screenRecordingPromise
36
61
  fps:(NSUInteger)fps
37
62
  codec:(long long)codec;
38
63
  {
39
64
  @synchronized (self) {
40
- self.fps = fps;
41
- self.codec = codec;
42
- self.screenRecordingPromise = screenRecordingPromise;
43
- self.startedAt = @([NSDate.date timeIntervalSince1970]);
65
+ _fps = fps;
66
+ _codec = codec;
67
+ _screenRecordingPromise = screenRecordingPromise;
68
+ _startedAt = @([NSDate.date timeIntervalSince1970]);
44
69
  }
45
70
  }
46
71
 
47
- - (void)reset;
72
+ - (nullable FBScreenRecordingPromise *)detachScreenRecordingPromise
48
73
  {
49
74
  @synchronized (self) {
50
- self.fps = 0;
51
- self.codec = 0;
52
- if (nil != self.screenRecordingPromise) {
53
- [XCTContext runActivityNamed:@"Video Cleanup" block:^(id<XCTActivity> activity){
54
- [activity addAttachment:(XCTAttachment *)self.screenRecordingPromise.nativePromise];
55
- }];
56
- self.screenRecordingPromise = nil;
57
- }
58
- self.startedAt = nil;
75
+ FBScreenRecordingPromise *detachedPromise = _screenRecordingPromise;
76
+ _fps = 0;
77
+ _codec = 0;
78
+ _screenRecordingPromise = nil;
79
+ _startedAt = nil;
80
+ return detachedPromise;
81
+ }
82
+ }
83
+
84
+ - (void)cleanupDetachedPromise:(nullable FBScreenRecordingPromise *)promise
85
+ {
86
+ if (nil == promise) {
87
+ return;
88
+ }
89
+ @try {
90
+ [XCTContext runActivityNamed:@"Video Cleanup" block:^(id<XCTActivity> activity){
91
+ [activity addAttachment:(XCTAttachment *)promise.nativePromise];
92
+ }];
93
+ } @catch (NSException *exception) {
94
+ [FBLogger logFmt:@"Failed to clean up screen recording attachment: %@", exception.reason];
59
95
  }
60
96
  }
61
97
 
98
+ - (void)reset;
99
+ {
100
+ FBScreenRecordingPromise *detachedPromise = [self detachScreenRecordingPromise];
101
+ [self cleanupDetachedPromise:detachedPromise];
102
+ }
103
+
62
104
  - (BOOL)resetIfPromiseIs:(FBScreenRecordingPromise *)screenRecordingPromise
63
105
  {
64
- // @synchronized is recursive, so -reset may take the very same lock again below.
106
+ FBScreenRecordingPromise *detachedPromise = nil;
65
107
  @synchronized (self) {
66
- if (self.screenRecordingPromise != screenRecordingPromise) {
108
+ if (_screenRecordingPromise != screenRecordingPromise) {
67
109
  return NO;
68
110
  }
69
- [self reset];
70
- return YES;
111
+ detachedPromise = [self detachScreenRecordingPromise];
71
112
  }
113
+ [self cleanupDetachedPromise:detachedPromise];
114
+ return YES;
72
115
  }
73
116
 
74
117
  - (nullable NSDictionary *)toDictionary
75
118
  {
76
- if (nil == self.screenRecordingPromise) {
77
- return nil;
78
- }
119
+ @synchronized (self) {
120
+ if (nil == _screenRecordingPromise) {
121
+ return nil;
122
+ }
79
123
 
80
- return @{
81
- @"fps": @(self.fps),
82
- @"codec": @(self.codec),
83
- @"uuid": [self.screenRecordingPromise identifier].UUIDString ?: [NSNull null],
84
- @"startedAt": self.startedAt ?: [NSNull null],
85
- };
124
+ return @{
125
+ @"fps": @(_fps),
126
+ @"codec": @(_codec),
127
+ @"uuid": [_screenRecordingPromise identifier].UUIDString ?: [NSNull null],
128
+ @"startedAt": _startedAt ?: [NSNull null],
129
+ };
130
+ }
86
131
  }
87
132
 
88
133
  @end
@@ -12,6 +12,8 @@
12
12
  #import "FBSession-Private.h"
13
13
  #import "FBExceptions.h"
14
14
  #import "FBConfiguration.h"
15
+ #import "FBScreenRecordingContainer.h"
16
+ #import "FBScreenRecordingPromise.h"
15
17
  #import "XCUIApplicationDouble.h"
16
18
 
17
19
  @interface FBSession (SystemApplicationTests)
@@ -70,6 +72,39 @@ static id (^FBSystemApplicationLookup)(void);
70
72
  }
71
73
  @end
72
74
 
75
+ @interface FBTestScreenRecordingPromise : FBScreenRecordingPromise
76
+ @property (nonatomic, strong) NSUUID *testIdentifier;
77
+ @property (nonatomic, copy, nullable) id (^onNativePromiseAccess)(void);
78
+ - (instancetype)initWithUUID:(NSUUID *)uuid
79
+ onNativePromiseAccess:(nullable id (^)(void))onNativePromiseAccess;
80
+ @end
81
+
82
+ @implementation FBTestScreenRecordingPromise
83
+ - (instancetype)initWithUUID:(NSUUID *)uuid
84
+ onNativePromiseAccess:(nullable id (^)(void))onNativePromiseAccess
85
+ {
86
+ XCTAttachment *attachment = [XCTAttachment attachmentWithString:@"video"];
87
+ if ((self = [super initWithNativePromise:attachment])) {
88
+ _testIdentifier = uuid;
89
+ _onNativePromiseAccess = [onNativePromiseAccess copy];
90
+ }
91
+ return self;
92
+ }
93
+
94
+ - (NSUUID *)identifier
95
+ {
96
+ return self.testIdentifier;
97
+ }
98
+
99
+ - (id)nativePromise
100
+ {
101
+ if (self.onNativePromiseAccess) {
102
+ return self.onNativePromiseAccess();
103
+ }
104
+ return [super nativePromise];
105
+ }
106
+ @end
107
+
73
108
  @interface FBSessionTests : XCTestCase
74
109
  @property (nonatomic, strong) FBSession *session;
75
110
  @property (nonatomic, strong) XCUIApplication *testedApplication;
@@ -93,6 +128,7 @@ static id (^FBSystemApplicationLookup)(void);
93
128
  ((FBAUTLaunchSession *)self.session).launchApplication.duringLaunch = nil;
94
129
  }
95
130
  FBSystemApplicationLookup = nil;
131
+ [FBScreenRecordingContainer.sharedInstance reset];
96
132
  [self.session kill];
97
133
  FBConfiguration.sharedInstance.shouldTerminateApp = self.shouldTerminateAppValue;
98
134
  [super tearDown];
@@ -265,4 +301,103 @@ static id (^FBSystemApplicationLookup)(void);
265
301
  }
266
302
  }
267
303
 
304
+ - (void)testScreenRecordingContainerResetClearsStateWhenCleanupThrows
305
+ {
306
+ FBScreenRecordingContainer *container = FBScreenRecordingContainer.sharedInstance;
307
+ FBTestScreenRecordingPromise *promise = [[FBTestScreenRecordingPromise alloc] initWithUUID:NSUUID.UUID
308
+ onNativePromiseAccess:^id{
309
+ @throw [NSException exceptionWithName:@"CleanupFailure" reason:@"Simulated attachment failure" userInfo:nil];
310
+ }];
311
+ [container storeScreenRecordingPromise:promise fps:24 codec:0];
312
+
313
+ XCTAssertNoThrow([container reset]);
314
+ XCTAssertNil(container.screenRecordingPromise);
315
+ XCTAssertNil(container.startedAt);
316
+ XCTAssertEqual(container.fps, 0U);
317
+ XCTAssertEqual(container.codec, 0LL);
318
+ XCTAssertNil([container toDictionary]);
319
+ }
320
+
321
+ - (void)testScreenRecordingContainerStateIsClearedDuringCleanup
322
+ {
323
+ FBScreenRecordingContainer *container = FBScreenRecordingContainer.sharedInstance;
324
+ __block FBScreenRecordingPromise *promiseDuringCleanup = nil;
325
+ __block NSNumber *startedAtDuringCleanup = nil;
326
+ __block NSDictionary *dictionaryDuringCleanup = nil;
327
+ XCTAttachment *attachment = [XCTAttachment attachmentWithString:@"video"];
328
+ FBTestScreenRecordingPromise *promise = [[FBTestScreenRecordingPromise alloc] initWithUUID:NSUUID.UUID
329
+ onNativePromiseAccess:^id{
330
+ promiseDuringCleanup = container.screenRecordingPromise;
331
+ startedAtDuringCleanup = container.startedAt;
332
+ dictionaryDuringCleanup = [container toDictionary];
333
+ return attachment;
334
+ }];
335
+ [container storeScreenRecordingPromise:promise fps:24 codec:1];
336
+
337
+ [container reset];
338
+ XCTAssertNil(promiseDuringCleanup);
339
+ XCTAssertNil(startedAtDuringCleanup);
340
+ XCTAssertNil(dictionaryDuringCleanup);
341
+ }
342
+
343
+ - (void)testScreenRecordingContainerResetAllowsConcurrentReplacementDuringCleanup
344
+ {
345
+ FBScreenRecordingContainer *container = FBScreenRecordingContainer.sharedInstance;
346
+ FBTestScreenRecordingPromise *replacement = [[FBTestScreenRecordingPromise alloc] initWithUUID:NSUUID.UUID
347
+ onNativePromiseAccess:nil];
348
+ XCTAttachment *attachment = [XCTAttachment attachmentWithString:@"video"];
349
+ FBTestScreenRecordingPromise *initial = [[FBTestScreenRecordingPromise alloc] initWithUUID:NSUUID.UUID
350
+ onNativePromiseAccess:^id{
351
+ XCTestExpectation *replacementStored = [self expectationWithDescription:@"Replacement stored during cleanup"];
352
+ dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{
353
+ [container storeScreenRecordingPromise:replacement fps:60 codec:1];
354
+ [replacementStored fulfill];
355
+ });
356
+ [self waitForExpectationsWithTimeout:2. handler:nil];
357
+ return attachment;
358
+ }];
359
+ [container storeScreenRecordingPromise:initial fps:24 codec:0];
360
+
361
+ XCTAssertTrue([container resetIfPromiseIs:initial]);
362
+ XCTAssertEqual(container.screenRecordingPromise, replacement);
363
+ XCTAssertEqual(container.fps, 60U);
364
+ XCTAssertEqual(container.codec, 1LL);
365
+ XCTAssertEqualObjects([container toDictionary][@"uuid"], replacement.identifier.UUIDString);
366
+ }
367
+
368
+ - (void)testScreenRecordingContainerStaleResetPreservesActiveRecording
369
+ {
370
+ FBScreenRecordingContainer *container = FBScreenRecordingContainer.sharedInstance;
371
+ __block BOOL didRunCleanup = NO;
372
+ XCTAttachment *attachment = [XCTAttachment attachmentWithString:@"video"];
373
+ FBTestScreenRecordingPromise *active = [[FBTestScreenRecordingPromise alloc] initWithUUID:NSUUID.UUID
374
+ onNativePromiseAccess:^id{
375
+ didRunCleanup = YES;
376
+ return attachment;
377
+ }];
378
+ FBTestScreenRecordingPromise *stale = [[FBTestScreenRecordingPromise alloc] initWithUUID:NSUUID.UUID
379
+ onNativePromiseAccess:nil];
380
+ [container storeScreenRecordingPromise:active fps:30 codec:1];
381
+
382
+ XCTAssertFalse([container resetIfPromiseIs:stale]);
383
+ XCTAssertFalse(didRunCleanup);
384
+ XCTAssertEqual(container.screenRecordingPromise, active);
385
+ XCTAssertEqual(container.fps, 30U);
386
+ XCTAssertEqual(container.codec, 1LL);
387
+ }
388
+
389
+ - (void)testScreenRecordingContainerResetOnEmptyContainer
390
+ {
391
+ FBScreenRecordingContainer *container = FBScreenRecordingContainer.sharedInstance;
392
+ [container reset];
393
+ FBTestScreenRecordingPromise *stale = [[FBTestScreenRecordingPromise alloc] initWithUUID:NSUUID.UUID
394
+ onNativePromiseAccess:nil];
395
+
396
+ XCTAssertNil([container toDictionary]);
397
+ XCTAssertNoThrow([container reset]);
398
+ XCTAssertFalse([container resetIfPromiseIs:stale]);
399
+ XCTAssertNil(container.screenRecordingPromise);
400
+ XCTAssertNil(container.startedAt);
401
+ }
402
+
268
403
  @end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "appium-webdriveragent",
3
- "version": "17.0.7",
3
+ "version": "17.0.8",
4
4
  "description": "Package bundling WebDriverAgent",
5
5
  "keywords": [
6
6
  "Appium",
@@ -83,5 +83,5 @@
83
83
  "node": "^22.22.2 || ^24.15.0 || >=26.0.0",
84
84
  "npm": ">=10"
85
85
  },
86
- "gitHead": "d7d177f55102776f22794034ff7337b9213610dd"
86
+ "gitHead": "e2a754f27f3d2b3c4932a16f71eaa2c49fbcedae"
87
87
  }