Skip to content

Revert "[input] Migrate fuchsia.ui.pointerinjector to TouchSource (#190855) - #191509

Merged
caroqliu merged 3 commits into
flutter:masterfrom
caroqliu:revert-190855
Aug 22, 2026
Merged

caroqliu merged 3 commits into
flutter:masterfrom
caroqliu:revert-190855

Conversation

@caroqliu

Copy link
Copy Markdown
Contributor

This reverts commit 7099814. See b/550157001

@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Aug 21, 2026
@github-actions github-actions Bot added a: text input Entering text in a text field or keyboard related problems engine flutter/engine related. See also e: labels. platform-fuchsia Fuchsia code specifically labels Aug 21, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the PointerInjectorDelegate class to manage the pointer injection lifecycle and handle related platform messages for embedded views on Fuchsia. The review feedback highlights several issues: potential 32-bit truncation of 64-bit timestamps and trace flow IDs, potential runner crashes from using FML_CHECK on optional or unbound services, the need to reset the device_ interface pointer to nullptr during Reset(), and a type mismatch between ViewId and view_id parameters.

Comment on lines +105 to +136
auto trace_flow_id = args.FindMember("traceFlowId");
if (!trace_flow_id->value.IsInt()) {
FML_LOG(ERROR) << "Argument 'traceFlowId' is not a int";
return false;
}

auto width = args.FindMember("logicalWidth");
if (!width->value.IsFloat() && !width->value.IsInt()) {
FML_LOG(ERROR) << "Argument 'logicalWidth' is not a float";
return false;
}

auto height = args.FindMember("logicalHeight");
if (!height->value.IsFloat() && !height->value.IsInt()) {
FML_LOG(ERROR) << "Argument 'logicalHeight' is not a float";
return false;
}

auto timestamp = args.FindMember("timestamp");
if (!timestamp->value.IsInt() && !timestamp->value.IsUint64()) {
FML_LOG(ERROR) << "Argument 'timestamp' is not a int";
return false;
}

PointerInjectorRequest event = {
.x = pointer_x->value.GetFloat(),
.y = pointer_y->value.GetFloat(),
.pointer_id = pointer_id->value.GetUint(),
.phase = static_cast<fup_EventPhase>(phase->value.GetInt()),
.trace_flow_id = trace_flow_id->value.GetUint64(),
.logical_size = {width->value.GetFloat(), height->value.GetFloat()},
.timestamp = timestamp->value.GetInt()};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The timestamp and trace_flow_id fields are parsed using GetInt() and checked with IsInt(). However, Fuchsia timestamps (zx_time_t) and trace flow IDs are 64-bit integers. Using GetInt() on a 64-bit timestamp will cause a 32-bit truncation/overflow, corrupting the timestamp and causing Fuchsia to reject the pointer events. We should use GetInt64() and IsInt64() / IsUint64() instead.

  auto trace_flow_id = args.FindMember("traceFlowId");
  if (!trace_flow_id->value.IsUint64() && !trace_flow_id->value.IsInt64()) {
    FML_LOG(ERROR) << "Argument 'traceFlowId' is not a uint64";
    return false;
  }

  auto width = args.FindMember("logicalWidth");
  if (!width->value.IsFloat() && !width->value.IsInt()) {
    FML_LOG(ERROR) << "Argument 'logicalWidth' is not a float";
    return false;
  }

  auto height = args.FindMember("logicalHeight");
  if (!height->value.IsFloat() && !height->value.IsInt()) {
    FML_LOG(ERROR) << "Argument 'logicalHeight' is not a float";
    return false;
  }

  auto timestamp = args.FindMember("timestamp");
  if (!timestamp->value.IsInt64() && !timestamp->value.IsUint64()) {
    FML_LOG(ERROR) << "Argument 'timestamp' is not a 64-bit int";
    return false;
  }

  PointerInjectorRequest event = {
      .x = pointer_x->value.GetFloat(),
      .y = pointer_y->value.GetFloat(),
      .pointer_id = pointer_id->value.GetUint(),
      .phase = static_cast<fup_EventPhase>(phase->value.GetInt()),
      .trace_flow_id = trace_flow_id->value.GetUint64(),
      .logical_size = {width->value.GetFloat(), height->value.GetFloat()},
      .timestamp = static_cast<zx_time_t>(timestamp->value.GetInt64())};

Comment on lines +244 to +282
void PointerInjectorDelegate::PointerInjectorEndpoint::RegisterInjector(
const PointerInjectorRequest& request) {
if (registered_) {
return;
}

fup_Config config;
config.set_device_id(1);
config.set_device_type(fup_DeviceType::TOUCH);
config.set_dispatch_policy(fup_DispatchPolicy::EXCLUSIVE_TARGET);

fup_Context context;
fuv_ViewRef context_clone;
fidl::Clone(*host_view_ref_, &context_clone);
context.set_view(std::move(context_clone));
config.set_context(std::move(context));

FML_CHECK(view_ref_.has_value());
fup_Target target;
fuv_ViewRef target_clone;

fidl::Clone(*view_ref_, &target_clone);
target.set_view(std::move(target_clone));
config.set_target(std::move(target));

fup_Viewport viewport;
viewport.set_viewport_to_context_transform(kIdentityMatrix);
std::array<std::array<float, 2>, 2> extents{
{/*min*/ {0, 0},
/*max*/ {request.logical_size[0], request.logical_size[1]}}};
viewport.set_extents(std::move(extents));
config.set_viewport(std::move(viewport));

FML_CHECK(registry_->is_bound());

(*registry_)->Register(std::move(config), device_.NewRequest(), [] {});

registered_ = true;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using FML_CHECK on view_ref_.has_value() and registry_->is_bound() will crash the runner process if the view reference is missing or if the system registry service disconnects. We should handle these cases gracefully by logging a warning and returning early.

void PointerInjectorDelegate::PointerInjectorEndpoint::RegisterInjector(
    const PointerInjectorRequest& request) {
  if (registered_) {
    return;
  }

  if (!view_ref_.has_value()) {
    FML_LOG(WARNING) << "Cannot register injector: view_ref_ is missing.";
    return;
  }

  if (!registry_ || !registry_->is_bound()) {
    FML_LOG(WARNING) << "Cannot register injector: registry is not bound.";
    return;
  }

  fup_Config config;
  config.set_device_id(1);
  config.set_device_type(fup_DeviceType::TOUCH);
  config.set_dispatch_policy(fup_DispatchPolicy::EXCLUSIVE_TARGET);

  fup_Context context;
  fuv_ViewRef context_clone;
  fidl::Clone(*host_view_ref_, &context_clone);
  context.set_view(std::move(context_clone));
  config.set_context(std::move(context));

  fup_Target target;
  fuv_ViewRef target_clone;

  fidl::Clone(*view_ref_, &target_clone);
  target.set_view(std::move(target_clone));
  config.set_target(std::move(target));

  fup_Viewport viewport;
  viewport.set_viewport_to_context_transform(kIdentityMatrix);
  std::array<std::array<float, 2>, 2> extents{
      {/*min*/ {0, 0},
       /*max*/ {request.logical_size[0], request.logical_size[1]}}};
  viewport.set_extents(std::move(extents));
  config.set_viewport(std::move(viewport));

  (*registry_)->Register(std::move(config), device_.NewRequest(), [] {});

  registered_ = true;
}

Comment on lines +284 to +288
void PointerInjectorDelegate::PointerInjectorEndpoint::Reset() {
injection_in_flight_ = false;
registered_ = false;
injector_events_ = {};
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

When resetting the endpoint state, we should explicitly unbind/reset the device_ interface pointer. Otherwise, calling device_.NewRequest() during a subsequent registration attempt will fail or assert because the interface pointer is still bound to the old, closed channel.

Suggested change
void PointerInjectorDelegate::PointerInjectorEndpoint::Reset() {
injection_in_flight_ = false;
registered_ = false;
injector_events_ = {};
}
void PointerInjectorDelegate::PointerInjectorEndpoint::Reset() {
injection_in_flight_ = false;
registered_ = false;
injector_events_ = {};
device_ = nullptr;
}

void OnDestroyView(uint64_t view_id) { valid_views_.erase(view_id); }

private:
using ViewId = int64_t;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The ViewId type is defined as int64_t, but OnCreateView and OnDestroyView take uint64_t view_id. We should make ViewId consistently uint64_t to avoid signed/unsigned mismatch warnings and implicit conversions.

Suggested change
using ViewId = int64_t;
using ViewId = uint64_t;

@caroqliu
caroqliu enabled auto-merge August 21, 2026 21:02
@caroqliu
caroqliu added this pull request to the merge queue Aug 21, 2026
Merged via the queue into flutter:master with commit 6391d39 Aug 22, 2026
28 checks passed
@caroqliu
caroqliu deleted the revert-190855 branch August 22, 2026 00:28
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Aug 22, 2026
Roll Flutter from c2437523d308 to 65c9a8dc60bc (195 revisions)

flutter/flutter@c243752...65c9a8d

2026-08-22 [email protected] Roll ICU from d578f2e8b7bd to 8cc91d9b6ab9 (1 revision) (flutter/flutter#191542)
2026-08-22 [email protected] Roll Skia from 666a9b3d5cf0 to ad2106c0bb64 (3 revisions) (flutter/flutter#191527)
2026-08-22 [email protected] Roll Fuchsia Test Scripts from KaOq3EE4qJ9fnaaaK... to 0iCv10IlKfiilEBOU... (flutter/flutter#191524)
2026-08-22 [email protected] [flutter_tools] Add tests for negative lookahead regex in test runner and batch entrypoints (flutter/flutter#191438)
2026-08-22 [email protected] Roll Skia from 0c37868737fa to 666a9b3d5cf0 (2 revisions) (flutter/flutter#191518)
2026-08-21 [email protected] Revert "[input] Migrate fuchsia.ui.pointerinjector to TouchSource (#190855) (flutter/flutter#191509)
2026-08-21 [email protected] Fixes windows gallery benchmarks by forcing mobile layout (flutter/flutter#191507)
2026-08-21 [email protected] [flutter_tools] Restrict WebAssetServer source resolution to source map extensions (flutter/flutter#191501)
2026-08-21 [email protected] Roll Skia from f6900c5b8439 to 0c37868737fa (2 revisions) (flutter/flutter#191504)
2026-08-21 [email protected] Refactor `FlutterDevice.connect` and VM service discovery (flutter/flutter#191221)
2026-08-21 [email protected] [flutter_tools] Fix crash when migrating flow-style exclude lists in analysis_options.yaml (flutter/flutter#191269)
2026-08-21 [email protected] [rules] Add packages/flutter_tools/gradle/AGENTS.md rules (flutter/flutter#191486)
2026-08-21 [email protected] [flutter_tools] refactor CLI argument architecture with typed option descriptors and bundles (PoC) (flutter/flutter#191018)
2026-08-21 [email protected] tools: Extract Dart SDK to temp directory before moving to final location (flutter/flutter#191263)
2026-08-21 [email protected] [web] Move CanvasKit fragment shader classes to canvaskit/fragment_shader.dart (flutter/flutter#191451)
2026-08-21 [email protected] Roll Fuchsia Linux SDK from GCQlmt6h-esJsNubS... to ic6GjOSn-KN508XyK... (flutter/flutter#191485)
2026-08-21 [email protected] [Widget Preview] Isolate PageStorage scope in widget preview group expansion tile (flutter/flutter#191378)
2026-08-21 [email protected] [flutter_tools] Deprecate --build and --no-build flags on flutter run (flutter/flutter#191358)
2026-08-21 [email protected] Roll Skia from 70988bed1b3b to f6900c5b8439 (2 revisions) (flutter/flutter#191481)
2026-08-21 [email protected] Roll Packages from 1785501 to 252bb33 (6 revisions) (flutter/flutter#191480)
2026-08-21 [email protected] Roll Fuchsia Linux SDK from 20IJas24bZiNmCZTK... to GCQlmt6h-esJsNubS... (flutter/flutter#191415)
2026-08-21 [email protected] Roll Skia from 2ba6971bd0d1 to 70988bed1b3b (2 revisions) (flutter/flutter#191476)
2026-08-21 [email protected] Roll Skia from 1d5f72537ba6 to 2ba6971bd0d1 (2 revisions) (flutter/flutter#191473)
2026-08-21 [email protected] Roll Skia from 2c25efd2e369 to 1d5f72537ba6 (1 revision) (flutter/flutter#191472)
2026-08-21 [email protected] Roll Skia from 09b1b810850a to 2c25efd2e369 (9 revisions) (flutter/flutter#191470)
2026-08-21 [email protected] [Impeller] fix position of cached single glyph text shadows (flutter/flutter#191325)
2026-08-21 [email protected] Roll Skia from abdf8821f313 to 09b1b810850a (15 revisions) (flutter/flutter#191458)
2026-08-21 [email protected] Document that programmatic TextEditingController changes do not run input formatters (flutter/flutter#190166)
2026-08-21 [email protected] Adds new gallery benchmarks to windows (skia and impeller) (flutter/flutter#191454)
2026-08-21 [email protected] iOS: Deprecate FlutterEngine.isGpuDisabled (flutter/flutter#191393)
2026-08-21 [email protected] Revert: [web] Unskip decoration image lerp tests (flutter/flutter#191462)
2026-08-20 [email protected] android_hardware_smoke_test: Improve reliability (flutter/flutter#191374)
2026-08-20 [email protected] Don't size or offset the Android platform view before it is laid out (flutter/flutter#190895)
2026-08-20 [email protected] [iOS][add2app] Skip building SwiftPM plugins when generating CocoaPods artifacts (flutter/flutter#190736)
2026-08-20 [email protected] Optimize JSONMessageCodec UTF-8 conversion (flutter/flutter#190529)
2026-08-20 [email protected] [FML] Replace deprecated wstring_convert with Win32 APIs (flutter/flutter#191394)
2026-08-20 [email protected] SliverFillRemaining extends beyond viewport size when fillOverscroll is true (flutter/flutter#191236)
2026-08-20 [email protected] [flutter_tools] Update argParser usageLineLength when --wrap-column is passed (flutter/flutter#191264)
2026-08-20 [email protected] [flutter_tools] Fix UNC path resolution in depfile parsing on Windows (flutter/flutter#191265)
2026-08-20 [email protected] [web] Unskip decoration image lerp tests (flutter/flutter#191426)
2026-08-20 [email protected] Do not inject 'type' and 'method' into service extension responses (flutter/flutter#190946)
2026-08-20 [email protected] [flutter_tools] Fix crash in symbolize command on stream error (flutter/flutter#191273)
2026-08-20 [email protected] [flutter_tools] Prevent deletion of shared native asset hooks outputs as stale (flutter/flutter#191272)
2026-08-20 [email protected] [flutter_tools] Support package wildcard assets in app pubspec (flutter/flutter#191266)
2026-08-20 [email protected] Add SliverClipRect and SliverClipRRect (flutter/flutter#179003)
2026-08-20 [email protected] [flutter_tools] Implement Diagnostics extension slice and doctor integration (flutter/flutter#191162)
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: text input Entering text in a text field or keyboard related problems CICD Run CI/CD engine flutter/engine related. See also e: labels. platform-fuchsia Fuchsia code specifically

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants