fluttercommunity / fluttercommunity/plus_plugins
[Bug]: [share_plus] Windows: hard crash on share() when the app has no implicit view (multi-window)
- Lingua principale
- Dart
- Stelle
- 1.9k
- Fork
- 1.3k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
### Platform
Windows 11 Pro 25H2 (10.0.26200.9168), x64
### Plugin
share_plus
### Version
13.3.0 (share_plus_platform_interface 7.2.0)
### Flutter SDK
3.48.0-1.0.pre-362, channel main, Dart 3.14.0
### Steps to reproduce
Calling `share()` on Windows kills the process instantly - no exception, no Dart error, nothing in the console. The app window just disappears.
It's a null dereference in the Windows plugin:
```cpp
// windows/share_plus_plugin.cpp:40
HWND SharePlusWindowsPlugin::GetWindow() {
return ::GetAncestor(registrar_->GetView()->GetNativeWindow(), GA_ROOT);
}
```
`GetView()` returns the implicit view, and the embedder only creates one if the engine actually has it:
```cpp
// cpp_client_wrapper/include/flutter/plugin_registrar_windows.h
FlutterDesktopViewRef implicit_view = FlutterDesktopPluginRegistrarGetView(core_registrar);
if (implicit_view) { implicit_view_ = std::make_unique(implicit_view); }
...
// DEPRECATED: Use |GetViewById| instead.
FlutterView* GetView() { return implicit_view_.get(); }
```
An app using the new experimental windowing (`enable-windowing: true`, `runWidget` + `WindowManager`) has no implicit view - the runner creates a bare `FlutterEngine` and windows are created from Dart. So `GetView()` returns null, and `GetWindow()` dereferences it.
Worth noting the embedder already marks `GetView()` deprecated in favour of `GetViewById`, precisely because there's no single implicit view once multi-window is in play.
To reproduce:
1. Start from Flutter's own multi-window sample (`examples/multiple_windows` in the SDK), or any app with `enable-windowing: true` whose `windows/runner/main.cpp` runs a bare `FlutterEngine` with no `FlutterViewController`.
2. Add `share_plus: ^13.3.0`.
3. Call `SharePlus.instance.share(ShareParams(text: 'hello'))` from a button.
4. Press it. The process dies on the spot.
**Expected:** either the share sheet opens, or the call fails with a `PlatformException` that Dart can catch.
**Actual:** access violation in the plugin, process gone, nothing logged.
I realise experimental windowing is a moving target and I'm not expecting the share sheet to work here. But a null check would turn a silent process kill into an error you can actually see, which is most of the pain. `GetViewById` looks like the real fix if the plugin can be told which window to anchor to.
### Code Sample
```dart
// main.dart - the multi-window shape, trimmed to the parts that matter
void main() {
WidgetsFlutterBinding.ensureInitialized();
runWidget(const MultiWindowApp());
}
// ... WindowManager(initialWindows: [WindowEntry(controller: ..., builder: ...)])
void _onSharePressed() {
SharePlus.instance.share(ShareParams(text: '1787392119')); // never returns
}
// windows/runner/main.cpp - no FlutterViewController, so no implicit view
auto const engine{std::make_shared(project)};
RegisterPlugins(engine.get());
engine->Run();
```
### Logs
```shell
[ +1 ms] The Flutter DevTools debugger and profiler on Windows is available at:
http://127.0.0.1:63384/wAZQr2_dWlo=/devtools/?uri=ws://127.0.0.1:63384/wAZQr2_dWlo=/ws
[+6899 ms] Service protocol connection closed.
[ +1 ms] Lost connection to device.
[ +1 ms] DevFS: Deleting filesystem on the device (file:///C:/Users/user/AppData/Local/Temp/myappf85f3646/myapp/)
[ +1 ms] DevFS: Deleted filesystem on the device (file:///C:/Users/user/AppData/Local/Temp/myappf85f3646/myapp/)
[ +3 ms] "flutter run" took 15,177ms.
[ +41 ms] Running 4 shutdown hooks
[ +20 ms] Shutdown hooks complete
[ +142 ms] exiting with code 0
```
### Flutter Doctor
```shell
[!] Flutter (Channel main, 3.48.0-1.0.pre-362, on Microsoft Windows [Version 10.0.26200.9168], locale en-US)
• Flutter version 3.48.0-1.0.pre-362 on channel main at C:\Programs\Develop\Flutter\main
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 68d6be5f9b (6 hours ago), 2026-08-22 04:47:17 +0000
• Engine revision 68d6be5f9b
• Dart version 3.14.0 (build 3.14.0-147.0.dev)
• DevTools version 2.61.0-dev.0
• Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-native-assets, enable-record-use, enable-swift-package-manager, omit-legacy-version-file, enable-windowing, enable-lldb-debugging, enable-uiscene-migration, enable-riscv64
[✓] Windows Version (Windows 11 or higher, 25H2, 2009)
[✗] Android toolchain - develop for Android devices
✗ Unable to locate Android SDK.
[✓] Chrome - develop for the web
[✓] Visual Studio - develop Windows apps (Visual Studio Community 2026 18.9.1)
• Visual Studio at C:\Program Files\Microsoft Visual Studio\18\Community
• Windows 10 SDK version 10.0.26100.0
[✓] Connected device (3 available)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.26200.9168]
[✓] Network resources
```
### Checklist before submitting a bug
- [x] I searched issues in this repository and couldn't find such bug/problem
- [x] I Google'd a solution and I couldn't find it
- [x] I searched on StackOverflow for a solution and I couldn't find it
- [x] I read the README.md file of the plugin
- [x] I'm using the latest version of the plugin
- [x] All dependencies are up to date with `flutter pub upgrade`
- [x] I did a `flutter clean`
- [x] I tried running the example project
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia da windows/share_plus_plugin.cpp e dalla configurazione Windows descritta nell'issue, quindi riproduci il problema usando Flutter's examples/multiple_windows sample. Verifica che chiamare share() senza una vista implicita non termini più il processo e produca invece il fallimento previsto che può essere intercettato quando il share sheet non può essere ancorato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- cpp, dart
- Ambito
- desktop, operating-systems
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Attiva
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 72/100