flutter / flutter/flutter

Breakpoints cannot be hit when located in SDK files. Modifications to source SDK files seem to be ignored when debugging

Open
#176,293 2 comments 0 reactions 0 assignees View on GitHub
a: debugging found in release: 3.35 found in release: 3.37 has reproducible steps p: material_ui P2 package platform-web team-web tool triaged-web
Dominant language
Dart
Stars
179k
Forks
31.1k
PR merge metrics
PR metrics pending

Description

### Steps to reproduce

1. mkdir workspace ; cd workspace
2. mkdir testpvapp ; cd testpvapp
3. flutter create .
4. launch VS Code and open the 'workspace' folder
5. Modify pubspec.yaml to include `web:` as a dependency and copy/paste into `main.dart` the code further below
6. Place a breakpoint on the line labelled as 'BRKPT' below (line 6)
7. Ctrl-click 'registerViewFactory' in the source code window (see below, line 6), this will open the SDK's `platform_view_registry.dart` file. Add another breakpoint on the first line of code in that function (`return ...`).
8. Launch a debug session using Chrome or Edge. In my setup, the displayed debugging configuration in the bottom blue bar (which is not visible before launching the debug session) is already set to `Debug my code + packages + SDK`, which is what is needed to reproduce the issue. Just make sure this option is selected.

We very briefly discussed this issue [here](https://github.com/Dart-Code/Dart-Code/issues/5731) with @DanTup.

### Expected results

The breakpoint in the `platform_view_registry.dart` file should be hit.

### Actual results

The breakpoint in the `platform_view_registry.dart` file is never hit.

When physically modifying the aforementionned `platform_view_registry.dart` file, adding a `print` statement or throwing an exception at the first line in the function body, we can see that this line is never executed. Doing a `flutter clean` and starting new debug session results in no improvement.

Amazingly, modifying patching all `platform_view_registry.dart` files found in the Flutter folder hierarchy also causes no `print` statement to be executed.

### Code sample

Code sample

```dart
import 'dart:ui_web' as ui;
import 'package:flutter/material.dart';
import 'package:web/web.dart' as web;

void main() {
ui.platformViewRegistry.registerViewFactory('google-iframe', (int viewId) { // BRKPT
final div = web.HTMLDivElement()
..textContent = 'Hello, world'
..style.width = '100%'
..style.height = '100%'
;
return div;
});

runApp(const MyApp());
}

class MyApp extends StatelessWidget {
const MyApp({super.key});

@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text("registerViewFactory example")),
body: const Center(
child: HtmlElementView(
viewType: 'google-iframe',
),
),
),
);
}
}
```

### Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

### Logs

Logs

```console
[Paste your logs here]
```

### Flutter Doctor output

Doctor output (the Flutter folder is modified because of the explanations above)

```console
[!] Flutter (Channel [user-branch], 3.35.3, on Microsoft Windows [version 10.0.26100.6584], locale fr-FR) [839ms]
! Flutter version 3.35.3 on channel [user-branch] at C:\Users\andy\Documents\flutter
Currently on an unknown channel. Run `flutter channel` to switch to an official channel.
If that doesn't fix the issue, reinstall Flutter by following instructions at https://flutter.dev/setup.
! Upstream repository unknown source is not a standard remote.
Set environment variable "FLUTTER_GIT_URL" to unknown source to dismiss this error.
• Framework revision a402d9a437 (4 weeks ago), 2025-09-03 14:54:31 -0700
• Engine revision ddf47dd3ff
• Dart version 3.9.2
• DevTools version 2.48.0
• Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-native-assets, enable-lldb-debugging
• If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[√] Windows Version (11 Pro 64-bit, 24H2, 2009) [3,1s]

[!] Android toolchain - develop for Android devices (Android SDK version 36.0.0) [6,5s]
• Android SDK at C:\Users\andy\AppData\Local\Android\sdk
• Emulator version 35.5.10.0 (build_id 13402964) (CL:N/A)
• Platform android-36, build-tools 36.0.0
• Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
This is the JDK bundled with the latest Android Studio installation on this machine.
To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
• Java version OpenJDK Runtime Environment (build 21.0.6+-13368085-b895.109)
! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses

[√] Chrome - develop for the web [214ms]
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.14.0) [212ms]
• Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
• Visual Studio Community 2022 version 17.14.36109.1
• Windows 10 SDK version 10.0.26100.0

[√] Android Studio (version 2024.3.2) [11ms]
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 21.0.6+-13368085-b895.109)

[√] VS Code (version 1.104.2) [9ms]
• VS Code at C:\Users\andy\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.118.0

[√] Connected device (4 available) [988ms]
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [version 10.0.26100.6584]
• Chrome (web) • chrome • web-javascript • Google Chrome 140.0.7339.208
• Edge (web) • edge • web-javascript • Microsoft Edge 140.0.3485.94

[√] Network resources [849ms]
• All expected network resources are available.

! Doctor found issues in 2 categories.
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.