readSnapshot method
Read the native surface. Always returns a non-null Scene; uses a sentinel scene when the AX tree is unavailable.
Implementation
@override
Future<Scene> readSnapshot() async {
try {
final result = await runBounded(
bridgePath,
['ax-snapshot', udid],
timeout: const Duration(seconds: 8),
phase: 'bridge ax-snapshot',
);
if (result.exitCode != 0) return _nativeSentinel();
final jsonStr = (result.stdout as String).trim();
if (jsonStr.isEmpty || jsonStr.startsWith('ax-snapshot:')) {
return _nativeSentinel();
}
final elements = jsonDecode(jsonStr) as List<dynamic>;
return _buildScene(elements);
} on Object {
return _nativeSentinel();
}
}