New issue
Advanced search Search tips

Issue 753431 link

Starred by 1 user

Issue metadata

Status: Available
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 3
Type: Bug



Sign in to add a comment

Mojo Bindings: Store interface handles as InterfacePtrInfo

Project Member Reported by roc...@chromium.org, Aug 8 2017

Issue description

Structs and message parameters take InterfacePtr for interface arguments, but they should probably instead take InterfacePtrInfo. This makes call sites slightly more verbose, but allows us to pass the owning object (be it a struct ptr, or an unserialized message context) across threads freely. We don't want an InterfacePtr to remain bound once it's been attached to a message.

This would allow lazy serialization to support methods which pass interfaces.
 

Comment 1 by roc...@chromium.org, Nov 10 2017

Labels: -Pri-3 Pri-1
Owner: roc...@chromium.org
Status: Started (was: Available)
Re-prioritizing this given that it's now impeding Network Service work.
Project Member

Comment 2 by bugdroid1@chromium.org, Nov 16 2017

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

commit 26efbd6cab9366d1edade79052d7381ad2f48bc8
Author: Ken Rockot <rockot@chromium.org>
Date: Thu Nov 16 04:39:49 2017

Mojo: Store interface fields as InterfacePtrInfo

Structs containing interfaces currently store the fields as
InterfacePtr. This is problematic because it prevents such a struct
from being safe to move across sequences.

Given that this is the only limiting factor making struct passing
non-sequence-safe, this changes the storage type to InterfacePtrInfo.

A few places which relied on the old behavior have been updated
accordingly, with varying degrees of inconvenience.

EDIT

Bug: 753431
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_site_isolation
Change-Id: I765a58a80a44ba61fed93c23a62578fb114a5245
Reviewed-on: https://chromium-review.googlesource.com/764988
Commit-Queue: Ken Rockot <rockot@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Marijn Kruisselbrink <mek@chromium.org>
Reviewed-by: Yuzhu Shen <yzshen@chromium.org>
Reviewed-by: Xiaohan Wang <xhwang@chromium.org>
Reviewed-by: John Abd-El-Malek <jam@chromium.org>
Reviewed-by: Daniel Murphy <dmurph@chromium.org>
Cr-Commit-Position: refs/heads/master@{#516988}
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/chrome/browser/prefs/profile_pref_store_manager.cc
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/chrome/browser/ui/views/ime_driver/ime_driver_mus.cc
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/content/browser/device_sensors/device_sensor_browsertest.cc
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/content/browser/frame_host/render_frame_host_impl.cc
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/content/browser/generic_sensor_browsertest.cc
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/content/browser/indexed_db/indexed_db_callbacks.cc
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/content/browser/service_worker/service_worker_fetch_dispatcher.cc
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/content/browser/service_worker/service_worker_installed_scripts_sender_unittest.cc
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/content/public/test/mock_render_thread.cc
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/content/public/test/render_view_test.cc
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/content/renderer/device_sensors/device_sensor_event_pump.h
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/content/renderer/indexed_db/indexed_db_callbacks_impl.cc
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/content/renderer/indexed_db/webidbdatabase_impl.cc
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/content/renderer/render_thread_impl.cc
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/content/renderer/render_view_impl.cc
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/content/renderer/service_worker/embedded_worker_instance_client_impl.cc
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/content/renderer/service_worker/web_service_worker_installed_scripts_manager_impl.cc
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/media/mojo/clients/mojo_renderer.cc
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/media/mojo/services/media_resource_shim.cc
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/media/mojo/services/media_resource_shim.h
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/media/mojo/services/media_service_unittest.cc
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/media/mojo/services/mojo_renderer_service.cc
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/media/mojo/services/mojo_renderer_service.h
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/mojo/public/cpp/bindings/interface_ptr.h
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/mojo/public/cpp/bindings/interface_ptr_info.h
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/mojo/public/cpp/bindings/lib/handle_interface_serialization.h
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/mojo/public/cpp/bindings/tests/data_view_unittest.cc
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/mojo/public/cpp/bindings/tests/handle_passing_unittest.cc
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/mojo/public/cpp/bindings/tests/union_unittest.cc
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/mojo/public/tools/bindings/generators/cpp_templates/interface_definition.tmpl
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/mojo/public/tools/bindings/generators/cpp_templates/interface_macros.tmpl
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_declaration.tmpl
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/mojo/public/tools/bindings/generators/cpp_templates/wrapper_class_definition.tmpl
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/mojo/public/tools/bindings/generators/cpp_templates/wrapper_union_class_declaration.tmpl
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/mojo/public/tools/bindings/generators/cpp_templates/wrapper_union_class_definition.tmpl
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/mojo/public/tools/bindings/generators/mojom_cpp_generator.py
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/services/device/generic_sensor/generic_sensor_service_unittest.cc
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/services/device/generic_sensor/sensor_provider_impl.cc
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/services/preferences/persistent_pref_store_impl.cc
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/services/preferences/pref_store_consistency_unittest.cc
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/services/preferences/public/cpp/persistent_pref_store_client.cc
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/services/preferences/public/cpp/tests/persistent_pref_store_client_unittest.cc
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/services/preferences/tracked/tracked_persistent_pref_store_factory.cc
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/services/ui/ime/ime_unittest.cc
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/services/ui/ime/test_ime_driver/test_ime_driver.cc
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/storage/browser/blob/blob_registry_impl.cc
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/storage/browser/blob/blob_registry_impl_unittest.cc
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/storage/browser/blob/blob_transport_strategy.cc
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/storage/browser/blob/blob_transport_strategy.h
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/storage/browser/blob/blob_transport_strategy_unittest.cc
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/third_party/WebKit/Source/core/dom/BlinkCloneableMessageStructTraits.cpp
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/third_party/WebKit/Source/modules/sensor/SensorProxy.cpp
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/third_party/WebKit/Source/platform/blob/BlobData.cpp
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/third_party/WebKit/Source/platform/blob/BlobDataTest.cpp
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/third_party/WebKit/common/message_port/cloneable_message.cc
[modify] https://crrev.com/26efbd6cab9366d1edade79052d7381ad2f48bc8/ui/aura/mus/input_method_mus.cc

Cc: austi...@google.com
Hi, I'm currently working on revoking interfaces on execution context disposal, which will need messages to use InterfacePtrInfo instead (at least in Blink code). Should I start working on this?
That would be great! The change should be a fairly straightforward
extension of the above CL, and I am happy to help if needed.

On Jan 3, 2018 11:30 PM, "austinct via monorail" <monorail+v2.3603455515@
chromium.org> wrote:
I'm not too sure how to approach this change - changing the generator code to use PtrInfo is not too bad, but it looks like there a lot of interface methods that take in InterfacePtrs, so changing all call sites to use PtrInfo types seems infeasible.
Typically with large codegen changes like this we introduce a flag in the
mojom GN rule (e.g. use_interface_ptr_info_params or something) and have it
default to the current behavior. Then we incrementally switch targets to
the new behavior until we're close enough to invert the default value. Then
we clean up the remaining uses of the (now non-default) old behavior and
wipe out the flag.

As it turns out, occurrence of passing an interface handle always generate
some code like this[1], and this means there is exactly one instance of the
code string "PtrDataView>(" generated per occurrence. Searching for this
over all files matching /.*mojom\.cc/ shows there are ~96 such interface
parameters in the tree.

It probably makes sense to do this incrementally then, though once the flag
is introduced I would probably carve the transition into only 5-6 follow-up
CLs, if not fewer. Could do one big CL too, it just depends on how much of
a stomach you have for rebasing 30 times while trying to land something :)

[1]
https://cs.chromium.org/chromium/src/out/Debug/gen/device/vr/vr_service.mojom-blink.cc?rcl=7606e3039bbcb4f3f1df3aee7db49a81116351a3&l=284
Alright, I got it thanks :)
Sorry, I'm going to have to drop this - it got reprioritized under other work, and now I don't have enough time to do it.
Owner: rockot@google.com
Cc: -austi...@google.com rockot@google.com
Labels: -Pri-1 Pri-3
Owner: ----
Status: Available (was: Started)
Cc: yutak@chromium.org

Sign in to add a comment