diff --git a/widget/cocoa/nsCocoaWindow.mm b/widget/cocoa/nsCocoaWindow.mm index b965ee108d74..c7338e94dd43 100644 --- a/widget/cocoa/nsCocoaWindow.mm +++ b/widget/cocoa/nsCocoaWindow.mm @@ -4609,12 +4609,15 @@ nsresult nsCocoaWindow::Create(nsIWidget* aParent, const DesktopIntRect& aRect, initWithFrame:mWindow.childViewFrameRectForCurrentBounds geckoChild:this]; mChildView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable; - [contentView addSubview:mChildView]; mNativeLayerRoot = NativeLayerRootCA::CreateForCALayer(mChildView.rootCALayer); mNativeLayerRoot->SetBackingScale(BackingScaleFactor()); + // Link mChildView into the native NSView hierarchy only after + // mNativeLayerRoot is initialized. This resolves bug 1986701. + [contentView addSubview:mChildView]; + [WindowDataMap.sharedWindowDataMap ensureDataForWindow:mWindow]; NS_ASSERTION(!mTextInputHandler, "mTextInputHandler has already existed");