In #13112, NVDAObjects.IAccessible.IAccessible._getIA2TargetsForRelationsOfType gained support for IAccessible2_2::relationTargetsOfType to make retrieval of relations faster. However, this code currently falls back to IAccessible2::nRelations and friends if there were no targets retrieved, even if relationTargetsOfType was successful. nRelations and friends can be slow because the server potentially has to calculate relations the client doesn't even want.
I think _getIA2TargetsForRelationsOfType should only fall back to the old method if relationTargetsOfType fails or is not supported. Currently, a warning is logged if this happens, but the code doesn't early return. If it succeeds, 0 targets is a valid return and should not result in a fallback.
I discovered this because we currently have a case in Firefox where calculation of a particular relation is a bit slow in large documents. It turns out that this particular relation isn't even supported by IA2, so I'm going to fix that, which will eliminate the user impact of this issue. Thus, I can't provide decent steps to reproduce here because the document is huge, which means you need to be using the new accessibility cache which isn't yet enabled by default, and because by the time anyone gets to this, the performance problem will probably no longer be observable due to my fix. Nevertheless, I think it's probably worth fixing this eventually for general performance.
In #13112,
NVDAObjects.IAccessible.IAccessible._getIA2TargetsForRelationsOfTypegained support for IAccessible2_2::relationTargetsOfType to make retrieval of relations faster. However, this code currently falls back to IAccessible2::nRelations and friends if there were no targets retrieved, even if relationTargetsOfType was successful. nRelations and friends can be slow because the server potentially has to calculate relations the client doesn't even want.I think
_getIA2TargetsForRelationsOfTypeshould only fall back to the old method if relationTargetsOfType fails or is not supported. Currently, a warning is logged if this happens, but the code doesn't early return. If it succeeds, 0 targets is a valid return and should not result in a fallback.I discovered this because we currently have a case in Firefox where calculation of a particular relation is a bit slow in large documents. It turns out that this particular relation isn't even supported by IA2, so I'm going to fix that, which will eliminate the user impact of this issue. Thus, I can't provide decent steps to reproduce here because the document is huge, which means you need to be using the new accessibility cache which isn't yet enabled by default, and because by the time anyone gets to this, the performance problem will probably no longer be observable due to my fix. Nevertheless, I think it's probably worth fixing this eventually for general performance.