Skip to content
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

Add iOS log filter for messages coming from extension modules. #842

Merged
merged 3 commits into from
Aug 24, 2022

Conversation

freakboy3742
Copy link
Member

@freakboy3742 freakboy3742 commented Aug 24, 2022

When the ctypes module is dynamically loaded, the source of log messages written to NSLog by Python is reported as the extension module, rather than the name of the app binary.

This mirrors the filter that is required for macOS apps, where libFFI is dynamically linked; on macOS, libffi is the source of NSLog messages.

PR Checklist:

  • All new features have been tested
  • All new features have been documented
  • I have read the CONTRIBUTING.md file
  • I will abide by the code of conduct

Copy link
Member

@mhsmith mhsmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not set up to test iOS yet, so just a couple of comments from reviewing the code:

@@ -351,6 +351,15 @@ def run_app(self, app: BaseConfig, udid=None, **kwargs):
) from e

# Start log stream for the app.
# The following sets up a log stream filter that looks for:
# 1. a log sender that matches that app binary; or,
# 2. a log sender of that is a Python exception module,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be "extension module"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... No, I've invented a whole new type of module. It gets around all that tedious code writing and just raises the inevitable exception for you :-)

(oops - fixed :-)

f'senderImagePath ENDSWITH "/{app.formal_name}"',
f'senderImagePath ENDSWITH "/{app.formal_name}"'
f' OR (processImagePath ENDSWITH "/{app.formal_name}"'
' AND senderImagePath ENDSWITH "-iphonesimulator.so")',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just include all messages where processImagePath ENDSWITH "/{app.formal_name}"? Is it because it would be too noisy? If so, it would be worth explaining that in a comment.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The process will generate lots of messages that aren't user-originated (all the usual noise generated by the device notifying system-level events). We only care about the messages that come from the user's code (the sender).

We could almost get away with just filtering on the senderImagePath. This would work on the simulator, and on any phone that only had 1 Python app running; but if you had a second app generating log messages, those would end up being interspersed with with the app you were trying to log.

Regardless - I'll add a note about this.

@codecov
Copy link

codecov bot commented Aug 24, 2022

Codecov Report

Merging #842 (cae87b9) into main (d013638) will increase coverage by 0.00%.
The diff coverage is n/a.

Impacted Files Coverage Δ
src/briefcase/platforms/iOS/xcode.py 94.54% <ø> (ø)
src/briefcase/integrations/rcedit.py 100.00% <0.00%> (ø)

@freakboy3742 freakboy3742 merged commit 48a0f0b into beeware:main Aug 24, 2022
@freakboy3742 freakboy3742 deleted the dynamic-loading branch August 24, 2022 23:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants