flushUICommand function

void flushUICommand(
  1. WebFViewController view,
  2. Pointer<NativeBindingObject> selfPointer
)

Implementation

void flushUICommand(WebFViewController view, Pointer<NativeBindingObject> selfPointer) {
  assert(_allocatedPages.containsKey(view.contextId));
  if (view.disposed) return;

  if (view.rootController.isFontsLoading) {
    SchedulerBinding.instance.scheduleFrameCallback((timeStamp) {
      flushUICommand(view, selfPointer);
    });
    return;
  }

  if (enableWebFProfileTracking) {
    WebFProfiler.instance.startTrackUICommand();
    WebFProfiler.instance.startTrackUICommandStep('readNativeUICommandMemory');
  }

  _NativeCommandData rawCommands = readNativeUICommandMemory(view.contextId);

  if (enableWebFProfileTracking) {
    WebFProfiler.instance.finishTrackUICommandStep();
  }

  List<UICommand>? commands;
  if (rawCommands.rawMemory.isNotEmpty) {
    if (enableWebFProfileTracking) {
      WebFProfiler.instance.startTrackUICommandStep('nativeUICommandToDart');
    }

    commands = nativeUICommandToDart(rawCommands.rawMemory, rawCommands.length, view.contextId);

    if (enableWebFProfileTracking) {
      WebFProfiler.instance.finishTrackUICommandStep();
      WebFProfiler.instance.startTrackUICommandStep('execUICommands');
    }

    execUICommands(view, commands);

    if (enableWebFProfileTracking) {
      WebFProfiler.instance.finishTrackUICommandStep();
    }

    SchedulerBinding.instance.scheduleFrame();
  }

  if (enableWebFProfileTracking) {
    WebFProfiler.instance.finishTrackUICommand();
  }
}