tripflex / WifiWizard2

A Cordova plugin for managing Wifi networks (new version of WiFiWizard) - Latest is version 3+
https://www.npmjs.com/package/cordova-plugin-wifiwizard2
Apache License 2.0
122 stars 146 forks source link

SCAN_FAILED after 4 scans #100

Open mishkeTz opened 4 years ago

mishkeTz commented 4 years ago

Prerequisites

Check all boxes if you have done the following:

Issue type

Select all that apply

Description

I have a button that triggers scan on click. When I try to scan for 5th time it fails with an error message 'SCAN_FAILED'. Every time after 4 successful scans it fails for no reason.

Steps to Reproduce

  1. Fresh cordova instalation
  2. Install this package and run WifiWizard2.scan().then((res) => { }).catch(() => { })
  3. Try it out on Android 9 (In my case Samsung S8)

Expected behavior: To get scan results.

Actual behavior: Get an error message 'SCAN_FAILED' after 4 successful scans. It always fails at 5th scan.

Reproduces how often: Every 5th scan.

Versions

Please include the plugin version that you are using and also include the OS, version and device you are using.

Plugin version: 3.1.1 Android: 9 Cordova: 9.0.0

EDIT: Maybe it has to do something with calling it too often and throttling of WiFi happens and the OS is blocking it? If someone more experienced can clarify this in more details I would appreciate it.

xLarry commented 4 years ago

I just googled your assumption regarding throttling and found the following:

Android 9: Each foreground app can scan four times in a 2-minute period. This allows for a burst of scans in a short time.

All background apps combined can scan one time in a 30-minute period.

Android 10 and higher: The same throttling limits from Android 9 apply. There is a new developer option to toggle the throttling off for local testing (under Developer Options > Networking > Wi-Fi scan throttling).

See: https://developer.android.com/guide/topics/connectivity/wifi-scan#wifi-scan-throttling

I guess we can close this then.

/cc: @tripflex