Support multi-window apps
Many desktop apps will use multiple windows, we should confirm that the UIManager properly supports multiple root views and that we can share the dispatcher behavior across windows (otherwise we'll need to configure multiple UIManager modules with different dispatcher threads).
@rozele I would like to have this feature. Do you have any plans to achieve this? Or if there are any directions or designs, maybe I could help.
I tweaked the 0.46 code to support multiple top level UWP windows, prototyping quality. Things covered:
- Added a new SecondaryReactPage base class (with MainComponentName abstract) that requires an externally provided IReactInstanceManager.
- Morphed existing UIViewOperationQueue into a per top level window construct: UIViewOperationQueue "master" and per window UIViewOperationQueueInstance objects. Each instance has a separate NativeViewHierarchyManager for simpicity (to avoid locking, etc.). A Dictionary<int, UIViewOperationQueueInstance> maps each react tag to the appropriate queue instance. New queues are created on demand when a root view is added, if needed. Queues register to CompositionTarget.Rendering in the context of the associated SizeMonitoringCanvas Dispatcher, and Windows subsequently calls OnRenderingSafe using same dispatcher (a nice and convenient undocumented feature).
Notes from Eric on things not covered (copying them here for safety):
I just did a rough comb through the code base. Here's a list of things we'll need to look into for multi-window:
- NativeAnimated drivers on secondary windows
- DevSupport on two windows (Can we refresh the entire app when focused on the second window, where is the dev options menu displayed, etc.?)
- DialogModule - (i.e., alert implementation) Do dialogs work across multiple windows?
- ClipboardModule - clipboard currently uses MainView dispatcher thread, how does it work on secondary windows?
- DeviceInfo - how do we get orientation changes and window size changes on multiple windows?
- StatusBarModule - StatusBar module also controls Window title bar, we should make that work for multiple windows
- Touch events - just need to do a general testing of switching window focus and stuff while pointers are being tracked to make sure nothing crashes
Closed by https://github.com/Microsoft/react-native-windows/pull/1615