question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ShadowCss.shimCssText slow after RC6 update

See original GitHub issue

I’m submitting a … (check one with “x”)

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

https://github.com/angular/angular/blob/38069aba35ac2914bb0a366036271a1388f7c275/modules/%40angular/compiler/src/shadow_css.ts#L151

The above line takes a few hundred milliseconds to run. See the attached JS profile:

![screen shot 2016-09-06 at 14 18 05](https://cloud.githubusercontent.com/assets/2276092/18271811/cba34238-743c-11e6-8a87-1bb8023b71b8.png)

If we include images as data urls in the css output, the performance is destroyed. The application startup might take anything from 5 to 30 seconds when having approx. 50 kB css included as component styles.

![screen shot 2016-09-06 at 13 18 19](https://cloud.githubusercontent.com/assets/2276092/18271843/0b1e1eb0-743d-11e6-8d35-9e3d7ca92c1f.png)

Expected/desired behavior

Shouldn’t take that long, RC5 did not have this issue.

Reproduction of the problem

Sample webpack configuration snippet

module: {
  loaders: [
    {test: /\.ts$/, exclude: [/\.spec\.ts$/, /node_modules/], loader: 'ts'},
    {test: /\.css$/, loader: 'raw'},
    {test: /\.html$/, loader: 'raw'},
    {test: /\.scss$/, loader: 'exports-loader?module.exports.toString()!css!postcss-loader!sass'},
    {test: /\.(png|jpg|gif)$/, exclude: /favicon\//, loader: 'url-loader?limit=8096&name=' + config.imageAssetPath }
  ],
  // ...
}

Component

@Component({
  styles: [require('./my.component.scss')]
})
class MyComponent {}

.scss (output is 70kB when minified)

$weather-map: (
  n600: "\e600",
  n500: "\e601",
  n440: "\e602",
  /* ~60 rows */
)
@each $name, $code in $weather-map {
  .weather-#{$name}:before {
    background-image: url('../../../images/weather-icons/#{$name}.png');
  }
}

Please tell us about your environment:

  • Angular version: 2.0.0-rc.6
  • Browser: all
  • Language: TypeScript 2.0.2

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:15 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
vicbcommented, Sep 7, 2016

@tobias74 @dcg thanks for the analysis.

we’ll do our best to include a fix in the next release as we understand it is important for dev mode.

1reaction
vicbcommented, Sep 8, 2016

@dcg thanks for the feedback - the fix has been merged

Read more comments on GitHub >

github_iconTop Results From Across the Web

angular: slow startup after upgrading to rc6 - Stack Overflow
Problem was solved: In rc6 a regular expression triggered so called "back-tracking" and thereby caused high cpu-load.
Read more >
UNPKG - @angular/compiler
n *\n * Typically, a template runs both the creation block and the update block on initialization and\n * subsequent runs only execute...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found