appium-webdriveragent 16.17.9 → 16.17.10

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
+ ## [16.17.10](https://github.com/appium/appium-ios/compare/appium-webdriveragent@16.17.9...appium-webdriveragent@16.17.10) (2026-11-05)
7
+
8
+ ### Bug Fixes
9
+
10
+ * **webdriveragent:** correct hinge angle undershoot on iOS 27.2 simulator ([#152](https://github.com/appium/appium-ios/issues/152)) ([b3ce495](https://github.com/appium/appium-ios/commit/b3ce495b49566f0eebff5192c5698d010e6c0ab1)), closes [#151](https://github.com/appium/appium-ios/issues/151)
11
+
12
+
6
13
  ## [16.17.9](https://github.com/appium/appium-ios/compare/appium-webdriveragent@16.17.8...appium-webdriveragent@16.17.9) (2026-11-04)
7
14
 
8
15
  ### Bug Fixes
@@ -30,7 +30,8 @@ NS_ASSUME_NONNULL_BEGIN
30
30
 
31
31
  /**
32
32
  Sends a simulated hinge angle in degrees (0 = closed, 180 = fully open).
33
- This dispatches the event; the display transition completes asynchronously.
33
+ Dispatches the event, then waits for the angle to settle and re-sends a slightly
34
+ nudged value if the reading is off (iOS 27.2 stops intermediate moves short).
34
35
  Verified on the iPhone Duo simulator; physical-device behavior is unverified.
35
36
  Does not change currentDisplayId.
36
37
  */
@@ -16,6 +16,22 @@
16
16
 
17
17
  #if !TARGET_OS_TV && !TARGET_OS_WATCH
18
18
  static const NSTimeInterval FBHingeAngleReadingTimeout = 5.0;
19
+ // iOS 27.2 stops the first move of a hinge gesture ~5% short. A following event with
20
+ // a slightly different value lands exactly, so we verify and correct after settling.
21
+ static const NSTimeInterval FBHingeSettleDelay = 0.4;
22
+ static const NSTimeInterval FBHingeSettlePollInterval = 0.15;
23
+ static const NSTimeInterval FBHingeSettleTimeout = 2.0;
24
+ static const double FBHingeSettledEpsilon = 0.01;
25
+ static const double FBHingeAngleTolerance = 0.05;
26
+ static const double FBHingeCorrectionNudge = 0.001;
27
+ static const NSUInteger FBHingeMaxCorrections = 2;
28
+ static const double FBHingeClosedAngle = 0.0;
29
+ static const double FBHingeOpenAngle = 180.0;
30
+
31
+ static BOOL FBHingeAnglesEqual(double first, double second)
32
+ {
33
+ return fabs(first - second) < FBHingeAngleTolerance;
34
+ }
19
35
 
20
36
  typedef CFDataRef (*FBIOCFSerialize)(CFTypeRef object, CFOptionFlags options);
21
37
  typedef CFTypeRef (*FBIOHIDEventCreateVendorDefinedEvent)(CFAllocatorRef allocator,
@@ -121,6 +137,16 @@ static const FBHingeInjectionAPI *FBHingeInjectionFunctions(void)
121
137
  return nil;
122
138
  }
123
139
  #if !TARGET_OS_TV && !TARGET_OS_WATCH
140
+ return [self fb_hingeAngleWithTimeout:FBHingeAngleReadingTimeout error:error];
141
+ #else
142
+ return nil;
143
+ #endif
144
+ }
145
+
146
+ #if !TARGET_OS_TV && !TARGET_OS_WATCH
147
+
148
+ - (nullable NSNumber *)fb_hingeAngleWithTimeout:(NSTimeInterval)timeout error:(NSError **)error
149
+ {
124
150
  id<FBAngleManager> manager = [FBAngleManagerClass() new];
125
151
  NSOperationQueue *queue = [NSOperationQueue new];
126
152
  queue.maxConcurrentOperationCount = 1;
@@ -144,7 +170,7 @@ static const FBHingeInjectionAPI *FBHingeInjectionFunctions(void)
144
170
  }
145
171
  [condition unlock];
146
172
  }];
147
- NSDate *deadline = [NSDate dateWithTimeIntervalSinceNow:FBHingeAngleReadingTimeout];
173
+ NSDate *deadline = [NSDate dateWithTimeIntervalSinceNow:timeout];
148
174
  [condition lock];
149
175
  while (nil == reading) {
150
176
  if (![condition waitUntilDate:deadline]) {
@@ -158,14 +184,13 @@ static const FBHingeInjectionAPI *FBHingeInjectionFunctions(void)
158
184
  }
159
185
  if (nil == result) {
160
186
  [[FBErrorBuilder.builder withDescriptionFormat:@"Timed out after %g seconds waiting for a valid hinge angle",
161
- FBHingeAngleReadingTimeout] buildError:error];
187
+ timeout] buildError:error];
162
188
  }
163
189
  return result;
164
- #else
165
- return nil;
166
- #endif
167
190
  }
168
191
 
192
+ #endif
193
+
169
194
  - (BOOL)fb_setSimulatedHingeAngle:(double)angle error:(NSError **)error
170
195
  {
171
196
  if (!isfinite(angle) || angle < 0 || angle > 180) {
@@ -175,6 +200,22 @@ static const FBHingeInjectionAPI *FBHingeInjectionFunctions(void)
175
200
  return [[FBErrorBuilder.builder withDescription:@"Hinge angle injection requires an available hinge and the IOKit HID APIs"] buildError:error];
176
201
  }
177
202
  #if !TARGET_OS_TV && !TARGET_OS_WATCH
203
+ if (![self.class fb_dispatchHingeAngle:angle error:error]) {
204
+ return NO;
205
+ }
206
+ if (self.fb_supportsHingeAngleReading) {
207
+ [self fb_correctHingeAngleToward:angle];
208
+ }
209
+ return YES;
210
+ #else
211
+ return NO;
212
+ #endif
213
+ }
214
+
215
+ #if !TARGET_OS_TV && !TARGET_OS_WATCH
216
+
217
+ + (BOOL)fb_dispatchHingeAngle:(double)angle error:(NSError **)error
218
+ {
178
219
  // WDA's fb_performIOHIDEventWithPage:usage:duration:error: uses XCDeviceEvent
179
220
  // with page, usage, and duration only. The XCDeviceEvent interfaces checked
180
221
  // in Xcode 27.1 provide no way to attach the vendor payload containing the
@@ -207,9 +248,52 @@ static const FBHingeInjectionAPI *FBHingeInjectionFunctions(void)
207
248
  CFRelease(client);
208
249
  }
209
250
  return canDispatch || [[FBErrorBuilder.builder withDescription:@"Cannot create the simulated hinge HID event or client"] buildError:error];
210
- #else
211
- return NO;
212
- #endif
213
251
  }
214
252
 
253
+ // Waits until two consecutive readings agree; nil if the angle never settles in time.
254
+ - (nullable NSNumber *)fb_settledHingeAngle
255
+ {
256
+ [NSThread sleepForTimeInterval:FBHingeSettleDelay];
257
+ NSDate *deadline = [NSDate dateWithTimeIntervalSinceNow:FBHingeSettleTimeout];
258
+ NSNumber *previous = nil;
259
+ NSTimeInterval remaining;
260
+ while ((remaining = [deadline timeIntervalSinceNow]) > 0) {
261
+ NSNumber *current = [self fb_hingeAngleWithTimeout:MIN(remaining, FBHingeAngleReadingTimeout) error:nil];
262
+ if (nil == current) {
263
+ return nil;
264
+ }
265
+ if (nil != previous && fabs(current.doubleValue - previous.doubleValue) < FBHingeSettledEpsilon) {
266
+ return current;
267
+ }
268
+ previous = current;
269
+ [NSThread sleepForTimeInterval:FBHingeSettlePollInterval];
270
+ }
271
+ return nil;
272
+ }
273
+
274
+ // Best effort: a failed read or correction never fails the original request.
275
+ - (void)fb_correctHingeAngleToward:(double)angle
276
+ {
277
+ // Identical consecutive values are ignored by the device, so each retry is nudged
278
+ // inward; values near the ends are not nudged outward as >170 snaps to 180.
279
+ double direction = angle <= 90 ? 1 : -1;
280
+ for (NSUInteger attempt = 0; attempt <= FBHingeMaxCorrections; ++attempt) {
281
+ NSNumber *reading = [self fb_settledHingeAngle];
282
+ // 0 and 180 are the device's snap points, so a reading there is final
283
+ if (nil == reading
284
+ || FBHingeAnglesEqual(reading.doubleValue, FBHingeClosedAngle)
285
+ || FBHingeAnglesEqual(reading.doubleValue, FBHingeOpenAngle)
286
+ || FBHingeAnglesEqual(reading.doubleValue, angle)
287
+ || attempt == FBHingeMaxCorrections) {
288
+ return;
289
+ }
290
+ double nudged = angle + direction * FBHingeCorrectionNudge * (attempt + 1);
291
+ if (![self.class fb_dispatchHingeAngle:nudged error:nil]) {
292
+ return;
293
+ }
294
+ }
295
+ }
296
+
297
+ #endif
298
+
215
299
  @end
@@ -15,11 +15,11 @@
15
15
  <key>CFBundlePackageType</key>
16
16
  <string>FMWK</string>
17
17
  <key>CFBundleShortVersionString</key>
18
- <string>16.17.9</string>
18
+ <string>16.17.10</string>
19
19
  <key>CFBundleSignature</key>
20
20
  <string>????</string>
21
21
  <key>CFBundleVersion</key>
22
- <string>16.17.9</string>
22
+ <string>16.17.10</string>
23
23
  <key>NSPrincipalClass</key>
24
24
  <string/>
25
25
  </dict>
@@ -130,6 +130,33 @@
130
130
  XCTAssertEqualObjects([self hingeResponseWithArguments:@{}][@"value"][@"error"], @"invalid argument");
131
131
  }
132
132
 
133
+ - (void)testHingeAngleReadbackMatchesRequestedAngle
134
+ {
135
+ #if TARGET_OS_SIMULATOR
136
+ XCUIDevice *device = XCUIDevice.sharedDevice;
137
+ XCTSkipUnless(device.fb_supportsHingeAngleReading && device.fb_canAttemptSimulatedHingeAngleInjection,
138
+ @"Requires a device with a hinge that supports reading and injection");
139
+ NSNumber *originalAngle = [device fb_getSimulatedHingeAngle:nil];
140
+ XCTAssertNotNil(originalAngle, @"Cannot read the original hinge angle");
141
+ if (nil == originalAngle) {
142
+ return;
143
+ }
144
+ [self addTeardownBlock:^{
145
+ [device fb_setSimulatedHingeAngle:originalAngle.doubleValue error:nil];
146
+ }];
147
+ // Intermediate angles are the ones iOS 27.2 initially stops short of
148
+ for (NSNumber *angle in @[@0, @45, @90, @150, @120, @10, @180]) {
149
+ NSError *error = nil;
150
+ XCTAssertTrue([device fb_setSimulatedHingeAngle:angle.doubleValue error:&error], @"%@", error);
151
+ NSNumber *reading = [device fb_getSimulatedHingeAngle:&error];
152
+ XCTAssertNotNil(reading, @"%@", error);
153
+ XCTAssertEqualWithAccuracy(reading.doubleValue, angle.doubleValue, 0.1, @"Requested %@", angle);
154
+ }
155
+ #else
156
+ XCTSkip(@"Hinge injection is only verified on simulators");
157
+ #endif
158
+ }
159
+
133
160
  - (void)testHingeAngleRejectsUnsupportedDevices
134
161
  {
135
162
  XCTSkipIf(XCUIDevice.sharedDevice.fb_canAttemptSimulatedHingeAngleInjection, @"Requires a device without an available hinge");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "appium-webdriveragent",
3
- "version": "16.17.9",
3
+ "version": "16.17.10",
4
4
  "description": "Package bundling WebDriverAgent",
5
5
  "keywords": [
6
6
  "Appium",
@@ -83,5 +83,5 @@
83
83
  "node": "^20.19.0 || ^22.12.0 || >=24.0.0",
84
84
  "npm": ">=10"
85
85
  },
86
- "gitHead": "afeb9cd03af16c7f3cea23633c82d715642c4e58"
86
+ "gitHead": "1da0348a440d0fa66f1b4b65d0334a9d164bc5ab"
87
87
  }