Repository navigation
[geocoding_android] Run pre-API 33 geocoder lookups off the main thread - #331
Draft
luanbatistadev wants to merge 1 commit into
Draft
luanbatistadev wants to merge 1 commit into
luanbatistadev wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On Android 12 and lower (API < 33),
placemarkFromCoordinatesandlocationFromAddressgo throughgetFromLocationPreAndroidApi33/getFromLocationNamePreAndroidApi33. Both are synchronous Pigeon host methods, so the blockingGeocoder.getFromLocation/Geocoder.getFromLocationNamecall runs on the platform main thread. When the geocoding service is slow (poor network, busyLocationManager), the main thread waits on a binder call and the app gets an ANR.We see this in production on Android 11 devices. The main thread stack of the ANR:
The same calls also show up as non-fatal
TimeoutException: Waited 5 seconds ... ReverseGeocodeerrors fromGeocoder.getFromLocationPreAndroidApi33.Change
@asyncinpigeons/geocoder.dartand regenerate the bindings with Pigeon 26.1.2. The Dart API is unchanged (the methods already returned aFuture).GeocoderProxyApinow runs the blocking lookup on a single background thread and delivers the result (or the error) back on the main thread throughProxyApiRegistrar.runOnMainThread, so the reply and theAddressproxy instances are still created on the main thread.Most of the diff in the generated files is ordering only: regenerating from the current
pigeons/geocoder.dartemitsGeographicBoundsafterGeocoder, which differs from the checked-in output. The functional change in the generated code is the async signature of the two methods.Pre-launch Checklist
pubspec.yamlwith an appropriate new version according to the pub versioning philosophy, or this PR does not need version changes.CHANGELOG.mdwith a new## x.y.zsection that matches the version inpubspec.yaml///).main.dart format .and committed any changes.flutter analyzeand fixed any errors.