New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 791969 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Dec 2017
Cc:
Components:
EstimatedDays: ----
NextAction: 2017-12-11
OS: Linux , Windows , Chrome , Mac
Pri: 1
Type: Bug

Blocked on:
issue 792490



Sign in to add a comment

LocalNTPTest.NonGoogleNTPLoadsWithoutError is flaky

Project Member Reported by treib@chromium.org, Dec 5 2017

Issue description

Dashboard: https://test-results.appspot.com/dashboards/flakiness_dashboard.html#tests=LocalNTPTest.NonGoogleNTPLoadsWithoutError

It's not *very* flaky, but still too much. Seems to be mostly on Linux CFI and occasionally on Win7.

I see two error cases:

1)
../../chrome/browser/ui/search/local_ntp_browsertest.cc:455: Failure
Value of: is_google
  Actual: true
Expected: false
(and then a bunch of histogram expectations fail, likely as a consequence of that)

2)
[1492:6768:1204/123459.701:ERROR:CONSOLE(0)] "Failed to find a valid digest in the 'integrity' attribute for resource 'chrome-search://local-ntp/config.js' with computed SHA-256 integrity '4xD3MlIY0P4FoUe54PC59x7yIMKf8d0awxMdDjjzxkA='. The resource has been blocked.", source: chrome-search://local-ntp/local-ntp.html (0)
[1492:6768:1204/123459.715:ERROR:CONSOLE(571)] "Uncaught ReferenceError: configData is not defined", source: chrome-search://local-ntp/local-ntp.js (571)
(and then the test times out, probably because it's waiting for some "finished loading" notification that never arrives)
 

Comment 1 by treib@chromium.org, Dec 5 2017

I'm guessing this is an actual race condition in LocalNtpSource: When the "is Google" state changes on the UI thread, we send that information to the IO thread asynchronously. Now if an NTP gets opened while that message is in flight, we can end up in a broken "half-Google" state, which would explain 2) above. Maybe some slightly different order of events can explain 1) too.


Ideas to fix this:

a) Split LocalNtpSource into a Google and a non-Google variant, serving from different URLs. This might be a good idea anyway, since the current sharing is somewhat confusing and brittle.
Downsides: Some code duplication, slightly more complex URL rewrite logic, and there will still be similar racing problems with Google base URL changes, which are also propagated from UI to IO thread.

b) Move LocalNtpSource::StartDataRequest to the IO thread (via URLDataSource::TaskRunnerForRequestPath). Probably *also* a good idea anyway, since the current thread hopping is broken (and has led to trouble in the past), and is hard to get right so will always be brittle at best.
Downsides: This will make accessing KeyedServices like LogoService and OneGoogleBarService (which live on the UI thread) more of a hassle.

Comment 2 by treib@chromium.org, Dec 5 2017

On further reflection, b) won't actually fix the race condition. Possible sequence of events after b) is implemented (all on the IO thread):
- is_google starts out true.
- local_ntp.html is served, containing checksum for config.js based on is_google==true.
- is_google gets set to false.
- config.js is served based on is_google==false.
- Checksum doesn't match.
- Boom.

I still think it's the right thing to do, it just won't fix this particular problem.

Comment 3 by treib@chromium.org, Dec 6 2017

Status: Started (was: Assigned)
Since neither a) nor b) will actually fix this, adding more ideas:

c) Introduce versioning for config.js: While serving local_ntp.html and inserting the checksum, also add a version suffix to the path of config.js ("config-1.js"), and cache the generated config along with the version number. Then when the config file is requested, we know which one to serve.
Problem: The checksum *also* goes into the CSP, and URLDataSource doesn't provide a way to tie CSP requests (GetContentSecurityPolicyScriptSrc) to actual file requests. I don't know how to solve this.

d) Load config.js dynamically (i.e. create a script tag from local_ntp.js). Then thanks to 'strict-dynamic', no checksum for config.js will be required (neither in the html nor in the CPS). Profit!
Potential downsides: It'll make the overall loading process a bit more complicated. This might have a perf impact, though it should be small. It might also make the setup for tests a bit more tricky, though I think that should work out.
Labels: zine-triaged

Comment 5 by treib@chromium.org, Dec 6 2017

Blockedon: 792490
Project Member

Comment 6 by bugdroid1@chromium.org, Dec 7 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/773623d293ed991e20596c4cb00e58610af5f395

commit 773623d293ed991e20596c4cb00e58610af5f395
Author: Marc Treib <treib@chromium.org>
Date: Thu Dec 07 15:17:16 2017

Local NTP: Load config.js dynamically

With this, no checksum is required for config.js anymore, which fixes a
race condition between serving the checksum and serving the contents
themselves. It also lets us remove quite a lot of plumbing :)

Bug:  792490 ,  791969 
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: I609ef274325bddb49bcbe6e90d58d35b7a385920
Reviewed-on: https://chromium-review.googlesource.com/811185
Commit-Queue: Marc Treib <treib@chromium.org>
Reviewed-by: Chris Pickel <sfiera@chromium.org>
Cr-Commit-Position: refs/heads/master@{#522428}
[modify] https://crrev.com/773623d293ed991e20596c4cb00e58610af5f395/chrome/browser/resources/local_ntp/local_ntp.css
[modify] https://crrev.com/773623d293ed991e20596c4cb00e58610af5f395/chrome/browser/resources/local_ntp/local_ntp.html
[modify] https://crrev.com/773623d293ed991e20596c4cb00e58610af5f395/chrome/browser/resources/local_ntp/local_ntp.js
[modify] https://crrev.com/773623d293ed991e20596c4cb00e58610af5f395/chrome/browser/search/local_ntp_source.cc
[modify] https://crrev.com/773623d293ed991e20596c4cb00e58610af5f395/chrome/browser/search/local_ntp_source.h
[modify] https://crrev.com/773623d293ed991e20596c4cb00e58610af5f395/chrome/test/data/local_ntp/local_ntp_browsertest.html

Project Member

Comment 7 by bugdroid1@chromium.org, Dec 8 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/71d761879bc76e7902d315c55ec0b9492dab0058

commit 71d761879bc76e7902d315c55ec0b9492dab0058
Author: Marc Treib <treib@chromium.org>
Date: Fri Dec 08 08:48:41 2017

Local NTP tests: Wait for TemplateURLService to load before using it

This might have been a cause of flakiness in these tests.

Bug:  791969 
Change-Id: I58d66ef67cd708c18fb902310c63aec29ea057b9
Reviewed-on: https://chromium-review.googlesource.com/814516
Reviewed-by: Chris Pickel <sfiera@chromium.org>
Commit-Queue: Marc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#522739}
[modify] https://crrev.com/71d761879bc76e7902d315c55ec0b9492dab0058/chrome/browser/ui/search/local_ntp_test_utils.cc

Comment 8 by treib@chromium.org, Dec 8 2017

NextAction: 2017-12-11

Comment 9 by treib@chromium.org, Dec 11 2017

Status: Fixed (was: Started)
This seems to have done it, no more flakes in the past 3 days.
The NextAction date has arrived: 2017-12-11

Sign in to add a comment