From 87be139332c51fbae0dd3ff462556d8fd0c566ab Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Wed, 21 Jun 2017 11:02:46 +0300 Subject: Load the debug window implementation asynchronously (#9026) Reduces the gzipped DefaultWidgetset eager bundle size from 345kb to 325kb. The relative impact is greater optimized widgetsets that might have down to around 150kb in the eager bundle. --- .../vaadin/client/ApplicationConfiguration.java | 108 +++++++++++---------- 1 file changed, 56 insertions(+), 52 deletions(-) diff --git a/client/src/main/java/com/vaadin/client/ApplicationConfiguration.java b/client/src/main/java/com/vaadin/client/ApplicationConfiguration.java index 3065a8a097..4c2583e493 100644 --- a/client/src/main/java/com/vaadin/client/ApplicationConfiguration.java +++ b/client/src/main/java/com/vaadin/client/ApplicationConfiguration.java @@ -714,56 +714,6 @@ public class ApplicationConfiguration implements EntryPoint { // Register pointer events (must be done before any events are used) PointerEventSupport.init(); - // Prepare the debugging window - if (isDebugMode()) { - /* - * XXX Lots of implementation details here right now. This should be - * cleared up when an API for extending the debug window is - * implemented. - */ - VDebugWindow window = VDebugWindow.get(); - - if (LogConfiguration.loggingIsEnabled()) { - window.addSection((Section) GWT.create(LogSection.class)); - } - window.addSection((Section) GWT.create(InfoSection.class)); - window.addSection((Section) GWT.create(HierarchySection.class)); - window.addSection((Section) GWT.create(NetworkSection.class)); - window.addSection((Section) GWT.create(TestBenchSection.class)); - if (Profiler.isEnabled()) { - window.addSection((Section) GWT.create(ProfilerSection.class)); - } - - if (isQuietDebugMode()) { - window.close(); - } else { - // Load debug window styles asynchronously - GWT.runAsync(new RunAsyncCallback() { - @Override - public void onSuccess() { - DebugWindowStyles dws = GWT - .create(DebugWindowStyles.class); - dws.css().ensureInjected(); - } - - @Override - public void onFailure(Throwable reason) { - Window.alert( - "Failed to load Vaadin debug window styles"); - } - }); - - window.init(); - } - - // Connect to the legacy API - VConsole.setImplementation(window); - - Handler errorNotificationHandler = GWT - .create(ErrorNotificationHandler.class); - Logger.getLogger("").addHandler(errorNotificationHandler); - } - if (LogConfiguration.loggingIsEnabled()) { GWT.setUncaughtExceptionHandler(new UncaughtExceptionHandler() { @@ -791,7 +741,62 @@ public class ApplicationConfiguration implements EntryPoint { // page once done compiling return; } - registerCallback(GWT.getModuleName()); + + if (isDebugMode()) { + // Load debug window bundle and continue the bootstrap sequence once + // it's loaded + GWT.runAsync(VDebugWindow.class, new RunAsyncCallback() { + @Override + public void onSuccess() { + initDebugWindow(); + registerCallback(GWT.getModuleName()); + } + + @Override + public void onFailure(Throwable reason) { + Window.alert("Failed to load Vaadin debug window"); + registerCallback(GWT.getModuleName()); + } + }); + } else { + // Continue the bootstrap sequence right away + registerCallback(GWT.getModuleName()); + } + } + + private static void initDebugWindow() { + /* + * XXX Lots of implementation details here right now. This should be + * cleared up when an API for extending the debug window is implemented. + */ + VDebugWindow window = VDebugWindow.get(); + + if (LogConfiguration.loggingIsEnabled()) { + window.addSection((Section) GWT.create(LogSection.class)); + } + window.addSection((Section) GWT.create(InfoSection.class)); + window.addSection((Section) GWT.create(HierarchySection.class)); + window.addSection((Section) GWT.create(NetworkSection.class)); + window.addSection((Section) GWT.create(TestBenchSection.class)); + if (Profiler.isEnabled()) { + window.addSection((Section) GWT.create(ProfilerSection.class)); + } + + if (isQuietDebugMode()) { + window.close(); + } else { + DebugWindowStyles dws = GWT.create(DebugWindowStyles.class); + dws.css().ensureInjected(); + + window.init(); + } + + // Connect to the legacy API + VConsole.setImplementation(window); + + Handler errorNotificationHandler = GWT + .create(ErrorNotificationHandler.class); + Logger.getLogger("").addHandler(errorNotificationHandler); } /** @@ -907,5 +912,4 @@ public class ApplicationConfiguration implements EntryPoint { private static final Logger getLogger() { return Logger.getLogger(ApplicationConfiguration.class.getName()); } - } -- cgit v1.2.3