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

I had to use internal for dynamic FrameName #69

Closed
YaLTeR opened this issue Sep 4, 2023 · 3 comments · Fixed by #71
Closed

I had to use internal for dynamic FrameName #69

YaLTeR opened this issue Sep 4, 2023 · 3 comments · Fixed by #71

Comments

@YaLTeR
Copy link
Contributor

YaLTeR commented Sep 4, 2023

Hi, I'm using tracy-client to profile a Wayland compositor. I'm using non-continuous frames for profiling monitor redrawing. However, with multiple monitors plugged in, every monitor should have its own frame set, as they are disjoint and redraw on their own vsync cycles.

Since monitors can be plugged in and out at runtime, I have to generate FrameNames dynamically, based on the name of the connector. I understand it's not really supported by Tracy at the moment, but it works well enough™ if I leak the name string, so that it's available for the remaining program lifetime. Unfortunately, I can't use the frame_name! macro as it only accepts a literal.

let vblank_frame_name = unsafe {
    tracy_client::internal::create_frame_name(format!("vblank on {output_name}\0").leak())
};

(I do this once when a monitor is connected, not every frame.)

Would it make sense to expose something for this in tracy-client?

@YaLTeR
Copy link
Contributor Author

YaLTeR commented Sep 4, 2023

wolfpld/tracy#608 I brought this up in Tracy, and the Tracy developer says that leaking the string like this is the intended solution here.

@nagisa
Copy link
Owner

nagisa commented Sep 4, 2023

Hum, I can see the use case and the motivation, but I’m not sure how to expose this in the API the right way. In particular, I guess we could add an API to FrameName, something like unsafe fn from_raw, but that wouldn't be really be much of an improvement, except that it wouldn’t be internal? Is that good enough? I don’t know.

@YaLTeR
Copy link
Contributor Author

YaLTeR commented Sep 5, 2023

Maybe some kind of FrameName::new_leak(String) which appends a \0 then leaks the result?

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 a pull request may close this issue.

2 participants