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

Issue 889965 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Last visit > 30 days ago
Closed: Sep 28
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Chrome
Pri: 2
Type: Bug
Proj-Servicification

Blocking:
issue 827532



Sign in to add a comment

TestingProfile::CreateNetworkContext causing an infinite loop

Project Member Reported by chongz@chromium.org, Sep 27

Issue description

```
network::mojom::NetworkContextPtr TestingProfile::CreateNetworkContext(
    bool in_memory,
    const base::FilePath& relative_partition_path) {
  if (base::FeatureList::IsEnabled(network::features::kNetworkService)) {
    network::mojom::NetworkContextPtr network_context;
    mojo::MakeRequest(&network_context);
    return network_context;
  }
  return nullptr;
}
```
Together with

```
void StoragePartitionImpl::InitNetworkContext() {
  network_context_ = GetContentClient()->browser()->CreateNetworkContext(
      browser_context_, is_in_memory_, relative_partition_path_);
  // ...
  network_context_.set_connection_error_handler(base::BindOnce(
      &StoragePartitionImpl::InitNetworkContext, weak_factory_.GetWeakPtr()));
```

Seems to cause an infinite loop since the returned |NetworkContextPtr| will trigger connection error handler immediately.

I'm working on a patch to strong bind a |network::TestNetworkContext|, which should at least fix the following two tests:
-ArcAuthServiceChildAccountTest.ChildTransition
-FileManagerPrivateApiTest.OnFileChanged

Not sure why it only happens on Chrome OS though.

 
TestingProfile could just gold onto the request itself (Which would effectively blackhole all usage of the mojo object, at least until shutdown)
Hmmmm sorry but I don't quite get the suggestion here. IIUC |TestingProfile::CreateNetworkContext()| has to return a valid pointer as discussed in:
https://chromium-review.googlesource.com/c/chromium/src/+/963402/7/chrome/test/base/testing_profile.cc#994

And my plan was to change it to:
```
network::mojom::NetworkContextPtr TestingProfile::CreateNetworkContext(
    bool in_memory,
    const base::FilePath& relative_partition_path) {
  if (base::FeatureList::IsEnabled(network::features::kNetworkService)) {
    network::mojom::NetworkContextPtr network_context;
    mojo::MakeStrongBinding(std::make_unique<network::TestNetworkContext>(),
                            mojo::MakeRequest(&network_context));
    return network_context;
  }
  return nullptr;
}
```

Does that sound reasonable? Thanks!

A mojo interface that is never listened to on the other end is still a valid pointer.  Calls can be made on it as will (And will never be responded to).

```
network::mojom::NetworkContextPtr TestingProfile::CreateNetworkContext(
    bool in_memory,
    const base::FilePath& relative_partition_path) {
  if (base::FeatureList::IsEnabled(network::features::kNetworkService)) {
    network::mojom::NetworkContextPtr network_context;
    network_context_request_ = mojo::MakeRequest(&network_context);
    return network_context;
  }
  return nullptr;
}
```

Should do basically the same thing, except it won't drop anything.  NetworkContext will DCHECK if Callback objects are passed to it, since it will drop them on the floor, and mojo has a hard requirement that Callbacks passed across a Mojo interface must be invoked (Unless the mojo pipe is closed first).  They can't just be destroyed.  Just not binding the request resolves that issue.
Ah I see, thanks for the explanation!
Project Member

Comment 5 by bugdroid1@chromium.org, Sep 28

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

commit 3431fc62c19d86cef97b82b3369093b5516da138
Author: Chong Zhang <chongz@chromium.org>
Date: Fri Sep 28 01:21:50 2018

NetworkService: Cache network_context_request_ in TestingProfile

This patch affects tests only.

We want to cache the |network_context_request_| to avoid triggering
connection error handler infinitely.

(Also organized unrelated BackgroundFetchBrowserTest.* tests)

Bug:  889965 
Change-Id: I9fc67b03f19b8a9575db7714ea57ec41fc0a7711
Reviewed-on: https://chromium-review.googlesource.com/1249727
Commit-Queue: Chong Zhang <chongz@chromium.org>
Reviewed-by: Matt Menke <mmenke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#594946}
[modify] https://crrev.com/3431fc62c19d86cef97b82b3369093b5516da138/chrome/test/base/testing_profile.cc
[modify] https://crrev.com/3431fc62c19d86cef97b82b3369093b5516da138/chrome/test/base/testing_profile.h
[modify] https://crrev.com/3431fc62c19d86cef97b82b3369093b5516da138/testing/buildbot/filters/mojo.fyi.chromeos.network_browser_tests.filter

Labels: M-71
Status: Fixed (was: Started)

Sign in to add a comment