Make duck player page more resilient to race conditions on macOS #571
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When implementing Duck Player on macOS - I encountered a race-condition where our script in the page is calling for a request/response before the special page has been marked as 'safe to receive messages' by the native side.
I looked into fixing it on their end, but it's heavily related to the fact that user-scripts are global and cannot be directly tied to a particular hostname.
So, I'm fixing it here by attempting (10 times) to make an 'initial connection' - once that's established we continue as normal.
This is a nice way of ensuring we can proceed across all platforms. So whilst it's technically a macOS only fix right now, it really helps everywhere by not giving up on first error.