-
Notifications
You must be signed in to change notification settings - Fork 94
App crashed #24
Comments
What is the error? I experience no crashes. Please share the full log. Where is your |
java.lang.NullPointerException |
Possible Ref:
But this is needs to be reported to Flutter and Google Maps directly, because this is a lower level problem within the Google Maps lib and I doubt there is anything I can do, except for redirecting the issue. Please answer my questions so I can forward this issue. Thanks. |
App crashes when calling navigator.pop in onPlacedPicked callback. E/AndroidRuntime(17945): FATAL EXCEPTION: GLThread 106 |
@TouseefAQ The example app does exactly this without crash: onPlacePicked: (PickResult result) {
setState(() {
selectedPlace = result;
Navigator.of(context).pop();
});
}, Can you share your code if it's different? Also, which device are you using? Can you reproduce the behavior on your device by pulling this repository and launching the example app on your device? Thank you in advance! |
Yes i have run the exact code from your repo and app crashes when runs on emulator running on Api 31. But have tested on on two different devices and didn't face any crash but have to check in ios side. |
I tested on API 31 emulator with architecture x86_64 with Flutter 3, no crash. Can you please explain me in detail what emulator you are using (device + architecture)? Also please copy paste the output of This is very important to me. Reproducing the issue would greatly help me to analyze it before redirecting the issue with more details, if I cannot fix it myself. Thank you. |
The same happened to me as well, although it's not 100% reproducible. I think it's a race condition and depends on how fast the connection/device is capable of loading data: on my bench I can reproduce it 30% of the times by immediately confirming the place after geolocation finishes. EDIT: I fixed it in the worst possible way with a fake loading: // Show location picker
PickResult location =
await showLocationPickerDialog(initialPosition: initialPosition);
// Fix for https://github.com/martin-braun/google_maps_place_picker_mb/issues/24
Navigator.of(context).push(MaterialPageRoute(builder: (_) => CircularProgressIndicator()));
await Future.delayed(Duration(milliseconds: 500));
Navigator.of(context).pop(); |
@mauriziopinotti Could you please share the output of |
Sure, here's the output of
I reproduced the issue on emulator Pixel 4 API 30 Android 11 x86_64 but also on various real devices (Galaxy S21 and others). |
@mauriziopinotti Thank you, I was able to re-produce the issue, eventually. I will try to find a fix to the problem and get back to you ASAP. I hope others in this thread will look at your post and understand how important it is to share the details that I request to find a solution. |
@mauriziopinotti It's hard to band-aid, let me tell you that. As you can read in the linked issue, the problem is a time-issue as you realized. I should've been more patient, it only happens to me in debug mode after 5 to 20 attempts, when I pick a place immediately without waiting too long. I suspect the Google Maps component is trying to check the length of an array that the components navigation-aware logic nulls on pop. I doubt that I can fix it, but I'm looking for a band-aid that isn't using a duration delay at this point. |
Sure, I totally get it. One thing I'd try is to wrap o clone the returned result on the native side as per my comment here: flutter/flutter#105965 (comment) I'll keep you posted if I'm able to come out with something useful (and robust). |
@mauriziopinotti Sure thing. Before we decide to report more details on their end (what they have to read and process), I want to clear things up on our end.
You said, over there. Seems weird to me, since our |
I investigated the wrapper (Flutter and Java part) and I don't see a way to prevent this issue. Further research shows that it's even a thing on ReactNative. Luckily the bug was reported to Google's issue tracker and hopefully it gets addressed ASAP. Unfortunately, any possible band-aid that comes into my mind cannot be applied here, since the exposed API is too limited. The My idea was to lock the pop until it fires, but there is still a slight risk of failure here, since the map view itself will invalidate two frames later. In the end, it doesn't even matter, because the callback is not available in Flutter at the moment. |
Awesome feedback!!! |
Here is a temporary fix. Unfortunately, I cannot apply it to my repository, but you can fix the problem by inserting the following to your pubspec.yaml: dependency_overrides:
google_maps_flutter:
git:
url: https://github.com/lukaskurz/plugins
path: packages/google_maps_flutter/google_maps_flutter
ref: main I recommend you to subscribe to this issue here, I will inform you when this has been fixed by the Google team, so that you can remove those lines again. Disclaimer: I am not responsible for any damage. You are obliged and required to check the source code of the repository that is containing the fix. By implementing the above fix, you agree to my disclaimer. |
Thx Martin for your efforts. This bug has been killing my app with 3% crash rate. Will try the git repo fix |
Looks like Google fixed this bug flutter/flutter#105965 (comment) It works according to my tests. Wondering about google_maps_place_picker_mb |
@giorgio79 I will look into this. |
@giorgio79 I updated the dependencies and unfortunately, I was forced to drop Flutter 2 support now, otherwise we wouldn't get access to the renderer initializer API. Please update your dependencies (incl. this package) and learn how you can trigger the latest renderer from the example. By using the latest renderer, the crashes won't appear anymore. Although some people complain the new renderer to still be very unstable and buggy, Google is probably working heavily on improving such renderer, thus the issue will be gone in the long run. Once Google decides the renderer is stable, the renderer will be selected by default. I consider this issue to be solved. Merry Christmas. |
@martin-braun 3.0.2 still in version. When the map is opened and then quickly closed, it gives the error here. |
@canibal1 Please upgrade to 3.1.1 my friend. |
@martin-braun Because google_maps_webservice 0.0.20-nullsafety.5 depends on http ^0.13.0 and no versions of google_maps_webservice match >0.0.20-nullsafety.5 <0.1.0, google_maps_webservice ^0.0.20-nullsafety.5 requires http ^0.13.0. |
@canibal1 You can read #56 carefully. The temporary solution is presented in https://github.com/martin-braun-net/google_maps_place_picker_mb/blob/3.1.1/example/pubspec.yaml#L37-L39, so you can move on for now. I know, this is not very beautiful, I don't consider it solved, it's just a necessity to move on. |
@martin-braun |
This is the same bug that opened this issue originally, and I explained how it can be solved 5(!) comments above your last comment. Please be kind to read: #24 (comment) and flutter/flutter#105965 Your app won't crash when you switch to the latest renderer. If you are still in doubt or have problems, please compile the example project at: https://github.com/martin-braun-net/google_maps_place_picker_mb/blob/master/example/lib/main.dart#L74-L76 It should not crash and it should show you how to leverage the latest renderer as well as how to switch hybrid composition which can help. |
@martin-braun This solution worked to me. Guys if you have problem you can run initRenderer() method before modal bottomsheet it's will not crash. @martin-braun thank you so much!!! |
Describe the bug
A clear and concise description of what the bug is.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
App should come on previous screen instead of crash
Screenshots
If applicable, add screenshots to help explain your problem.
Flutter Doctor -v
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: