-
-
Notifications
You must be signed in to change notification settings - Fork 56
Description
Describe the bug
Hi π
I was testing a way to force discovery to send more queries (or at higher frequency) using Riverpod's refresh/invalidate, because I had some issues with my embedded device being discovered and stumbled upon this issue. There is no stack trace provided, even when running flutter in verbose. This happens to me on macOS (14.3.1, M1 Max), but have reports indicating that it also happens on Windows (Windows 10 Pro).
To Reproduce
Steps to reproduce the behavior:
Minimal repro project is here: https://github.com/karniv00l/bonsoir_issue
And code looks like that:
// ignore_for_file: avoid_print
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:bonsoir/bonsoir.dart';
final deviceDiscoveryProvider = Provider<BonsoirDiscovery>((ref) {
final discovery = BonsoirDiscovery(type: '_testing._udp');
discovery.ready.then((value) {
discovery.eventStream!.listen(((event) => print('[Event] ${event.type}')));
print('Starting');
discovery.start();
});
ref.onDispose(() async {
print('Stopping');
await discovery.stop();
print('Stopped');
});
return discovery;
});
void main() {
runApp(const ProviderScope(child: MyApp()));
}
class MyApp extends ConsumerWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
ref.watch(deviceDiscoveryProvider);
Timer.periodic(const Duration(seconds: 1), (timer) {
ref.invalidate(deviceDiscoveryProvider);
});
return const MaterialApp(
title: 'Bonsoir test',
home: Scaffold(body: Center(child: Text('Hello World'))),
);
}
}The app will randomly crash after a couple of seconds without any errors/stack trace.
Expected behavior
App should not crash without any errors
Desktop (please complete the following information):
- OS: 14.3.1, M1 Max and Windows 10 Pro
Additional context
Going back to my initial problem - polling/querying for the service - is there any way this can be configured? It looks like the default behavior is exponential back off.