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

cpu_profiler.py uses tempfile before closing it on window 10 problems #734

Open
dvdface opened this issue Mar 8, 2024 · 1 comment
Open

Comments

@dvdface
Copy link

dvdface commented Mar 8, 2024

on Window 10, can't push file before close it. it will cause adb push failure
https://raw.githubusercontent.com/google/perfetto/main/tools/cpu_profile

`
def record_trace(config, profile_target):
"""Runs Perfetto with the provided configuration to record a trace.

Args:
config: The Perfetto config to be used for tracing/profiling.
profile_target: The directory where the recorded trace is output.
"""
NULL = open(os.devnull)
NO_OUT = {
'stdout': NULL,
'stderr': NULL,
}
if not release_or_newer('T'):
sys.exit("This tool requires Android T+ to run.")

#Push configuration to the device.
tf = tempfile.NamedTemporaryFile()
tf.file.write(config.encode('utf-8'))
tf.file.flush()
profile_config_path = '/data/misc/perfetto-configs/config-' + UUID
adb_check_output(['adb', 'push', tf.name, profile_config_path])
tf.close()
`

should change to

`
def record_trace(config, profile_target):
"""Runs Perfetto with the provided configuration to record a trace.

Args:
config: The Perfetto config to be used for tracing/profiling.
profile_target: The directory where the recorded trace is output.
"""
NULL = open(os.devnull)
NO_OUT = {
'stdout': NULL,
'stderr': NULL,
}
if not release_or_newer('T'):
sys.exit("This tool requires Android T+ to run.")

#Push configuration to the device.
tf = tempfile.NamedTemporaryFile(delete=False)
tf.file.write(config.encode('utf-8'))
tf.file.flush()
tf.close()
profile_config_path = '/data/misc/perfetto-configs/config-' + UUID
adb_check_output(['adb', 'push', tf.name, profile_config_path])
os.remove(tf.name)
`

@primiano
Copy link
Collaborator

Can you please send a patch following https://perfetto.dev/docs/contributing/getting-started ?

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

No branches or pull requests

2 participants