Skip to content

Icon resize task blocks the main thread during build #171

@jhnns

Description

@jhnns

Version

2.6.0

Reproduction link

https://github.com/jhnns/nuxt-pwa-build-perf-demo

Steps to reproduce

  • Create an initial nuxt project with create-nuxt-app and select the PWA module
  • Run node --inspect-brk ./node_modules/.bin/nuxt
  • Open Chrome and go to chrome://inspect/#devices
  • Select Node process and create a profile

What is expected ?

The icon resize task should start as soon as possible in a different process/thread to speed up the build.

What is actually happening?

Here is a flamegraph that demonstrates that the icon resize task takes up more than half of the build time. But the bigger problem is that the task blocks the main thread which means that webpack can't start to do its work in the mean time. Here I've marked the resize task with red:
Bildschirmfoto 2019-03-30 um 17.57.58 Kopie.jpg

You can see that webpack starts its work only after around 16s.

Additional comments?

Spinning up a separate process doesn't come for free. Usually it's better to have a separate thread for this kind of task. We could do this with Node.js worker threads (https://nodejs.org/api/worker_threads.html) which are only available for Node >10.

This bug report is available on Nuxt community (#c116)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions