-
-
Notifications
You must be signed in to change notification settings - Fork 626
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Store NVDA process ID in globalVars and use it consistently in the entire code base. #13646
Conversation
See test results for failed build of commit c22b531ceb |
1fe5e68
to
bb3af1e
Compare
I wonder, why NVDA can't use UIA in it's controls? |
Using UIA from your own process still seems to cause lockups/freezes
unfortunately.
This has been true since UIA was introduced in Windows 7.
|
Some (probably academic) thoughts: Do we have any reason to believe that os.getpid() has a performance cost? If not, I wonder whether it'd make sense to switch everything to use that for the sake of being more standard. I think we might have assumed it did once upon a time (the logic being that function calls must be more expensive), but I doubt that was ever actually measured.
It does look like os.getpid is slightly slower:
So os.getpid takes 1.5x the time of a global variable... but this is probably insignificant given the number of calls we make. Still, it also costs us nothing to optimise it, so maybe it's worthwhile to have the variable. 🤷♂️ |
I don't think testing with a class attribute here makes sense as we never stored PID on a class - it was either stored at a module level or as a local variable inside the function. As demonstrated below this seems to make a difference (I've tested just with a module level variable though). Based on your example:
The results are:
The module level variable is the fastest of these tree it seems. To have a full picture I've also measured how slow is a module attribute variable, by creating a module called
The results are:
To summarize while looking up a variable from an different module is a little bit faster than
Optimizing this code path was not a goal of this PR indeed. Obviously having a performance measurements here is nice, but this probably is more of a style discussion at this point than anything else. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies for the late review.
LGTM other than a minor typo, which I can fix when merging.
I am not including the deprecation notice in the changelog, as we do not plan to remove this code. The |
A very minor point, but isn't it customary to capitalize PID entirely? It is so
in Microsoft docs.
Thus: globalVars.appPID
Also, what is the reason this is "appPid"--I.E. why the "app" instead of just
pid? In globalVars, there shouldn't be any other PID expected, should there?
|
See test results for failed build of commit f49501363d |
This follows the way in which other variables in |
IMO, if there is the warning, there should also be the change log information. There is no point for add-on developers to discover by chance in the log that a variable is deprecated. On the opposite, if there should not be a preferred way to access the process ID, issuing a deprecation warning makes no sense. Note: Indicating a deprecation does not require to specify a removal date for the old syntax. It just indicates that there is a preferred syntax to use. |
I think either removing the warning or adding the changelog item is fine in this instance. |
+1 to this. |
I agree with @CyrilleB79.
If a developer does see the warning in the log, and tries then to find it in the
changelog and can't, it will probably be thought to be an error. This seems
inconsistent. IMHO it should be specified both ways.
|
Link to issue number:
None, noticed when working on #13366
Summary of the issue:
Process ID of NVDA is retrieved and used inconsistently in the code base:
appModuleHandler
we're storing it as a module level variable when initializing, however it is also pointlessly reinitialized when user re-initializes appModules - this makes no sense as process ID is constant during NVDA's life time.os.getpid
GetCurrentProcessId
is used directly.Description of how this pull request fixes the issue:
NVDA process ID is stored in
globalVars
when NVDA starts - all usages ofos.getpid
andGetCurrentProcessId
now use the new variable. SinceappModuleHandler.NVDAProcessID
is gone appropriate backward compatibility solution for add-ons has been implemented.Testing strategy:
appModuleHandler.NVDAProcessID
logs a deprecation warning but the process ID is returnedappModuleHandler
raises proper exceptionKnown issues with pull request:
None known
Change log entries:
For Developers
appModuleHandler.NVDAProcessID
is deprecated - useglobalVars.appPid
instead.Code Review Checklist: