Skip to content

Commit b01fe9c

Browse files
committed
added timeout
1 parent ab3c777 commit b01fe9c

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

ios/accessibility/accessibility_control.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,12 +312,24 @@ func (a *ControlInterface) extractCaptionText(innerValue map[string]interface{})
312312
}
313313

314314
// QueryAttributeValue queries any string attribute (Label, Identifier, Value, etc.) for an element
315+
// Uses 500ms timeout to prevent hanging if device doesn't respond
315316
func (a *ControlInterface) QueryAttributeValue(platformElementValue string, attributeName string) (string, error) {
316317
platformElementBytes, err := base64.StdEncoding.DecodeString(platformElementValue)
317318
if err != nil {
318319
return "", fmt.Errorf("invalid platformElementValue base64: %w", err)
319320
}
320-
return a.queryAttributeValue(platformElementBytes, attributeName), nil
321+
322+
resultChan := make(chan string, 1)
323+
go func() {
324+
resultChan <- a.queryAttributeValue(platformElementBytes, attributeName)
325+
}()
326+
327+
select {
328+
case result := <-resultChan:
329+
return result, nil
330+
case <-time.After(500 * time.Millisecond):
331+
return "", fmt.Errorf("timeout after 500ms querying attribute %s", attributeName)
332+
}
321333
}
322334

323335
// QueryLabelValue is a convenience wrapper for QueryAttributeValue with "Label"

0 commit comments

Comments
 (0)