-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
iOS PlatformView was designed around the assumption that the app code is the source of the truth of the PlatformView's frame. Currently, there is no code in the PlatformViewsController to prevent a PlatformView developer to make the PlatformView rendering outside of its parent view. They can simply add an origin and the embedded UIView will render outside of the widget's frame.
This violates some assumptions in the PlatformView code.
For example:
- PlatformView's overlay frame is calculated based on the ChildClippingView's frame, which is the parent of the embedded UIView.
- PlatformView's touch event is handled by the touch interceptor view, which is the parent of the embedded UIView. The embedded UIView is assumed to be the same frame of the touch interceptor view.
- Rendering offscreen breaks certain functionalities of PlatformView, for example, the blur filter does not work properly when the embedded UIView is offscreen.
The frame of embeddedView contains 2 parts: origin and size.
The PlatformView's size is correct due to the autoresizing mask.
The PlatformView's origin is not always correct as it is not enforced anywhere. Our own scenario tests also used a (50, 50) as origin of the PlatformView, which should be prevented.
We should add an enforcement in the PlatformViewController so that the origin of the PlatformView will never be none-zero. Because this might break some PlatformViews if they were using a none-zero origin, we should do this in 2-stepped release.
- 1. Add a FML_DCHECK at every frame to check the origin of the PlatformView. Add a warning message if the origin is none-zero. Update the scenario app to use zero origin.
- 2. Add a logic that if the origin of the PlatformView is none-zero, resets the origin to zero. Update the warning message to indicate such reset has happend.