-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
register failed, the sensor listeners size has exceeded the maximum limit 128 #139
Comments
My guess (but it's just a guess) is that the Future<void> onResume() async {
timer = Timer.periodic(frequency, (Timer t) {
onSamplingStart();
subscription = bufferingStream?.listen(onSamplingData,
onError: onError, onDone: onDone);
Timer(duration, () async {
await subscription?.cancel();
onSamplingEnd();
await getDatum().then((datum) {
if (datum != null) controller.add(datum);
}).catchError(
(error, stacktrace) => controller.addError(error, stacktrace));
});
});
} The Before issue #114 the stream would have been paused but this would not cause the error. |
I tested if the cancel was actually called by setting the oncancel method in the android code of the light package to
The method seems to be called (I see 'do the cancellation' and 'done the cancellation') BUT |
Ok, I solved the bug. In the onlisten you put
Otherwise your class variable I will now try to do my very first pull request, as I was not a frequent Githubber before I started using Flutter :) |
Solving problems of issue cph-cachet/carp.sensing-flutter#139 in onListen the class variable sensorEventListener should be set, not a new variable. Otherwise the onCancel method doesn't work: the sensorEventListener variable is still null in onCancel and nothing is unregistered.
Thanks. Has merged your PR now. The light plugin is released as v. 1.0.1. This will be updated in CAMS release v. 0.11.0. |
Solving problems of issue cph-cachet/carp.sensing-flutter#139 in onListen the class variable sensorEventListener should be set, not a new variable. Otherwise the onCancel method doesn't work: the sensorEventListener variable is still null in onCancel and nothing is unregistered.
Solving problems of issue cph-cachet/carp.sensing-flutter#139 in onListen the class variable sensorEventListener should be set, not a new variable. Otherwise the onCancel method doesn't work: the sensorEventListener variable is still null in onCancel and nothing is unregistered.
When I use the simple Flutter example app and add the light measure to my CARP study I get the following error (tested on Android phone and emulator):
Failed to open event stream
To reproduce you can add the following code:
After about 128 seconds you get the error. You can also increase the duration in the frequency parameter (e.g. by using SamplingSchema.common()), but in that case you have to wait longer to reproduce the error. I think I get the error because the stream is not correctly cancelled.
When I was playing around myself with foreground services a while ago I had the same problem when I used your light package. I solved it by adapting the sensor package to include a light sensor. This package and code did not seem to have the cancelling problem.
Flutter doctor -v
I use
carp_mobile_sensing: ^0.10.1
The text was updated successfully, but these errors were encountered: