{"action":"created","issue":{"url":"https://api.github.com/repos/cefsharp/CefSharp/issues/985","labels_url":"https://api.github.com/repos/cefsharp/CefSharp/issues/985/labels{/name}","comments_url":"https://api.github.com/repos/cefsharp/CefSharp/issues/985/comments","events_url":"https://api.github.com/repos/cefsharp/CefSharp/issues/985/events","html_url":"https://github.com/cefsharp/CefSharp/issues/985","id":71660900,"number":985,"title":"Wpf: ChromiumWebBrowser throws a NullReferenceException if its ActualSize changes before it appears in the VisualTree","user":{"login":"jamespearce2006","id":12157851,"avatar_url":"https://avatars.githubusercontent.com/u/12157851?v=3","gravatar_id":"","url":"https://api.github.com/users/jamespearce2006","html_url":"https://github.com/jamespearce2006","followers_url":"https://api.github.com/users/jamespearce2006/followers","following_url":"https://api.github.com/users/jamespearce2006/following{/other_user}","gists_url":"https://api.github.com/users/jamespearce2006/gists{/gist_id}","starred_url":"https://api.github.com/users/jamespearce2006/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jamespearce2006/subscriptions","organizations_url":"https://api.github.com/users/jamespearce2006/orgs","repos_url":"https://api.github.com/users/jamespearce2006/repos","events_url":"https://api.github.com/users/jamespearce2006/events{/privacy}","received_events_url":"https://api.github.com/users/jamespearce2006/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/cefsharp/CefSharp/labels/wpf","name":"wpf","color":"5319e7"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":17,"created_at":"2015-04-28T18:07:14Z","updated_at":"2015-05-01T14:12:35Z","closed_at":null,"body":"If a ChromiumWebBrowser is created outside the visual tree (because it's in a tab that's not yet been opened, for example), any changes to its ActualSize throw an exception. This might happen if the tab in question provides a preview tooltip, or needs to render the control into a RenderTargetBitmap for some other reason.\r\n\r\nThe exception occurs in CreateOffscreenBrowserWhenActualSizeChanged(), and occurs because source is still null.\r\n\r\nSome example code that demonstrates the problem.\r\n\r\n    private void Button_Click(object sender, RoutedEventArgs e)\r\n    {\r\n        const double width = 640d;\r\n        const double height = 480d;\r\n\r\n        ChromiumWebBrowser webBrowser = new ChromiumWebBrowser();\r\n        webBrowser.Address = \"www.google.com\";\r\n\r\n        Viewbox viewBox = new Viewbox();\r\n        viewBox.Child = webBrowser;\r\n        viewBox.Measure(new Size(width, height));\r\n        viewBox.Arrange(new Rect(0, 0, width, height));\r\n        viewBox.UpdateLayout();\r\n\r\n        RenderTargetBitmap bitmap = new RenderTargetBitmap((int) width, (int) height, 96, 96, PixelFormats.Pbgra32);\r\n        bitmap.Render(viewBox);\r\n\r\n        Image img = new Image();\r\n        img.Source = bitmap;\r\n\r\n        content.Content = img;\r\n    }\r\n\r\nAdditionally, content seems to reload as the ChromiumWebBrowser is added and removed from the VisualTree.\r\n"},"comment":{"url":"https://api.github.com/repos/cefsharp/CefSharp/issues/comments/98141969","html_url":"https://github.com/cefsharp/CefSharp/issues/985#issuecomment-98141969","issue_url":"https://api.github.com/repos/cefsharp/CefSharp/issues/985","id":98141969,"user":{"login":"jamespearce2006","id":12157851,"avatar_url":"https://avatars.githubusercontent.com/u/12157851?v=3","gravatar_id":"","url":"https://api.github.com/users/jamespearce2006","html_url":"https://github.com/jamespearce2006","followers_url":"https://api.github.com/users/jamespearce2006/followers","following_url":"https://api.github.com/users/jamespearce2006/following{/other_user}","gists_url":"https://api.github.com/users/jamespearce2006/gists{/gist_id}","starred_url":"https://api.github.com/users/jamespearce2006/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jamespearce2006/subscriptions","organizations_url":"https://api.github.com/users/jamespearce2006/orgs","repos_url":"https://api.github.com/users/jamespearce2006/repos","events_url":"https://api.github.com/users/jamespearce2006/events{/privacy}","received_events_url":"https://api.github.com/users/jamespearce2006/received_events","type":"User","site_admin":false},"created_at":"2015-05-01T14:12:35Z","updated_at":"2015-05-01T14:12:35Z","body":"Done - it's my first ever one..."}}