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

iOS: Avoid different player plugins from having an implicit order in which they need to be applied #561

Open
A1shK opened this issue Dec 16, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@A1shK
Copy link
Contributor

A1shK commented Dec 16, 2024

Is your feature request related to a problem? Please describe.

As a user, I want to load two plugins - PluginXYZ and PluginABC.

Let's say PluginABC, sets an environment object for the player view. Example:

player.hooks?.view.tap(name: "SwiftUI-environment", { view in
            AnyView(
                view
                    .environmentObject(environment)
            )
})

If I register my plugins in the order:

  1. PluginXYZ
  2. PluginABC

Then its possible that there is a crash when a capability is relying on PluginXYZ but uses the environment object set in PluginABC.

Describe the solution you'd like
Suggestion by @hborawski:

In order to prevent this, we could introduce a SwiftUIPlugin protocol that extends NativePlugin and adds an additional function that builds on top of SwiftUI's transformEnvironment

This would allow plugins like PluginABC to register a handler that sets up the environment, and then SwiftUIPlayer can apply all the environment modifications at once, rather than it being done per plugin, wrapping the view. This would remove this implicit dependency between the two plugins and ensure that all the environment modifications are done wrapping around the root view

Additional context

@A1shK A1shK added the enhancement New feature or request label Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant