Language:

Categories

Getting Started

General Use

JavaScript Integration

WPF

Windows Forms

MonoMac

Unity

Changelogs

Web-View Initialization Sequence

.NET Language:

Events Sequence

It is important to understand the sequence of events that occur when a native web-view is being wrapped by an Awesomium.NET component. Below is a list of events in the Awesomium.NET API, that are being fired once during the initialization of all IWebView instances, in that order:

  1. IWebView.InitializeView: Fired right before a native web-view is wrapped. This is the last moment that properties that cannot be changed when IsLive is true, can be set.
  2. WebCore.CreatedView: Fired when the new Web-View component is added to the WebCore.Views collection.
  3. IWebView.NativeViewInitialized: Fired after the native web-view is created, initialization is complete and settings have been applied to view.
  4. IWebView.ProcessCreated: Fired when it’s certain that the child process of the view (awesomium_process), has been started. This is usually when the first page starts loading.

All these events are only fired once for the lifetime of the component.

Initialization Sequence

The following presents the detailed initialization sequence for all managed web-view components on MS Windows and helps you decide the moment certain operations can be performed on the component:

WebView Component

  1. The component is being created (either through WebCore.CreateWebView or, for child views, through the relevant constructor). All steps are performed simultaneously during construction. For offscreen views only, it is now safe to access or call members on the IWebView instance.
  2. For windowed views you should now set the IWebView.ParentWindow property (the view cannot create a window until a parent is set).
    • You can now safely access or call members on the IWebView instance.

WPF WebControl Component

  1. The component is created.
  2. The component is initialized (InitalizeComponent of self and then of parent container, if any).
  3. The visual tree is being built and Styles are applied (see OnApplyTemplate)
    - or -
    The control is loaded for presentation for the first time (see Loaded).
  4. IWebView.InitializeView is fired. This is the moment to set any of the following properties, if they have not been set in the designer:
  5. A new native web-view is instanciated and wrapped or, for child views, the native view assigned to WebControl.NativeView is being wrapped.
  6. IsLive is true.
  7. The component is added to WebCore.Views.
  8. WebCore.CreatedView is fired.
  9. Additional initialization is performed, such as:
    • Applying settings specified at design-time (if WebControl.ViewType is set to Offscreen).
    • Preparing Javascript Interoperation.
    • Registering for events.
    • Creating internal helpers.
  10. If WebControl.ViewType is set to Window:
    • The HwndHost hosting the windowed view is added to the visual tree and is initialized.
    • IWebView.ParentWindow is internally set.
    • Settings specified at design-time are being applied.
  11. IWebView.NativeViewInitialized is fired.
  12. The source assigned to WebControl.Source or the default blank page (about:blank) is being loaded.
  13. IWebView.ProcessCreated is fired.
    • You can now start accessing the DOM of the loaded page. For subsequent navigations, wait for the IWebView.DocumentReady event.

WinForms WebControl Component

  1. The component is created.
  2. The component is initialized (InitalizeComponent of self and then of parent container, if any). This is the right moment to set any of the following properties, if they have not been set in the designer:
  3. The control's handle is created and HandleCreated is fired.
  4. IWebView.InitializeView is fired. This is the latest moment to set any of the following properties, if they have not been set in the designer:
  5. A new native web-view is instanciated and wrapped or, for child views, the native view assigned to WebControl.NativeView is being wrapped.
  6. IsLive is true.
  7. The component is added to WebCore.Views.
  8. WebCore.CreatedView is fired.
  9. Additional initialization is performed, such as:
    • Applying settings specified at design-time.
    • Preparing Javascript Interoperation.
    • Registering for events.
    • Creating internal helpers.
  10. IWebView.NativeViewInitialized is fired.
  11. The source assigned to WebControl.Source or the default blank page (about:blank) is being loaded.
  12. IWebView.ProcessCreated is fired.
    • You can now start accessing the DOM of the loaded page. For subsequent navigations, wait for the IWebView.DocumentReady event.