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 Redraw Safety to Pipify Modifier #23

Open
Sherlouk opened this issue Jul 10, 2022 · 2 comments
Open

Add Redraw Safety to Pipify Modifier #23

Sherlouk opened this issue Jul 10, 2022 · 2 comments

Comments

@Sherlouk
Copy link
Contributor

SwiftUI redraws views often, this is a big part of it's architecture to allow for quick and dynamic updates to views. Unfortunately, this causes issues with Pipify because it regenerates the PIP controller every time.

This has been seen in this Twitter thread (https://twitter.com/aoverholtzer/status/1546249575748358144) and my own experiences.

We need to ensure we protect against this.

@Sherlouk
Copy link
Contributor Author

Not 100% sure on how to approach this so any input is value.

One potential idea I've been exploring (and relates partially to #3 and #13) is around having a single Pipify controller for the entire application.

We would simply switch the underlying view if the developer wants to support multiple (different) experiences. This could be done with a singleton quite trivially and would eliminate this issue entirely.

I also think by disconnecting the experience from the controller we can help with performance - this is because we wouldn't need to be constantly rendering the view in the background. We would only do this when the user wants to present PIP.

This helps with performance across the board (CPU, memory, battery impact), resolves the issue with multiple controllers, and keeps the simple API.

@adamtow
Copy link

adamtow commented Jul 11, 2022

I'd second the singleton controller. I've seen the reinitialization of the Pipify controller in my app. This might prevent the Pipify view from toggling on and off:

isPresented changed to true
2022-07-11 08:32:46.734661-0700 MixEffect[553:28587] [Pipify] activating audio session
2022-07-11 08:32:46.755616-0700 MixEffect[553:28587] [Pipify] starting picture in picture
2022-07-11 08:32:46.756007-0700 MixEffect[553:28587] [Pipify] failed to start: Failed to start picture in picture.
2022-07-11 08:32:46.760434-0700 MixEffect[553:28587] [Pipify] configuring audio session
2022-07-11 08:32:46.760749-0700 MixEffect[553:28587] [Pipify] creating pip controller
2022-07-11 08:32:46.769115-0700 MixEffect[553:28587] [Pipify] isPresented changed to false
2022-07-11 08:32:46.769139-0700 MixEffect[553:28587] [Pipify] stopping picture in picture
2022-07-11 08:32:46.769146-0700 MixEffect[553:28587] [Pipify] deactivating audio session

@Sherlouk Sherlouk mentioned this issue Feb 4, 2024
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