Skip to content
This repository has been archived by the owner on Apr 10, 2024. It is now read-only.

App crashed #24

Closed
sheikh112233 opened this issue May 28, 2022 · 28 comments
Closed

App crashed #24

sheikh112233 opened this issue May 28, 2022 · 28 comments
Assignees
Labels
type:bug This is a bug that needs to be fixed

Comments

@sheikh112233
Copy link

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. search location '...'
  2. Click on check or tick button '....'
  3. See error

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.

@martin-braun
Copy link
Member

What is the error? I experience no crashes. Please share the full log. Where is your flutter doctor -v output? Also, if logs show nothing, can you please share device logs? On what device are you testing?

@martin-braun martin-braun added state:unclear This issue needs further clarification type:bug This is a bug that needs to be fixed labels May 28, 2022
@rehamalraee24
Copy link

java.lang.NullPointerException
Attempt to get length of null array
java.nio.ByteBufferAsIntBuffer.put (ByteBufferAsIntBuffer.java:122)
com.google.maps.api.android.lib6.gmm6.vector.gl.buffer.n.i (n.java:2)
com.google.maps.api.android.lib6.gmm6.vector.gl.buffer.n.d (n.java:3)
com.google.maps.api.android.lib6.gmm6.vector.gl.drawable.d.s (d.java:2)
com.google.maps.api.android.lib6.gmm6.vector.gl.drawable.ao.s (ao.java:12)
com.google.maps.api.android.lib6.gmm6.vector.bz.s (bz.java:29)
com.google.maps.api.android.lib6.gmm6.vector.bs.b (bs.java:151)
com.google.maps.api.android.lib6.gmm6.vector.av.run (av.java:48)

@martin-braun
Copy link
Member

  • Please share the output of flutter doctor -v.
  • Please tell me if this happens anytime or just sometimes.
  • Could you please disable minifyEnabled and shrinkResources in your gradle.build to see if the crashes continue

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.

@TouseefAQ
Copy link

TouseefAQ commented Jun 28, 2022

App crashes when calling navigator.pop in onPlacedPicked callback.

E/AndroidRuntime(17945): FATAL EXCEPTION: GLThread 106
E/AndroidRuntime(17945): Process: com.bravosix.logisticsapp, PID: 17945
E/AndroidRuntime(17945): java.lang.NullPointerException: Attempt to get length of null array
E/AndroidRuntime(17945): at java.nio.ByteBufferAsIntBuffer.put(ByteBufferAsIntBuffer.java:122)
E/AndroidRuntime(17945): at com.google.maps.api.android.lib6.gmm6.vector.gl.buffer.n.i(:com.google.android.gms.dynamite_mapsdynamite@221514104@22.15.14 (190800-0):2)
E/AndroidRuntime(17945): at com.google.maps.api.android.lib6.gmm6.vector.gl.buffer.n.d(:com.google.android.gms.dynamite_mapsdynamite@221514104@22.15.14 (190800-0):3)
E/AndroidRuntime(17945): at com.google.maps.api.android.lib6.gmm6.vector.gl.drawable.d.s(:com.google.android.gms.dynamite_mapsdynamite@221514104@22.15.14 (190800-0):2)
E/AndroidRuntime(17945): at com.google.maps.api.android.lib6.gmm6.vector.gl.drawable.ao.s(:com.google.android.gms.dynamite_mapsdynamite@221514104@22.15.14 (190800-0):12)
E/AndroidRuntime(17945): at com.google.maps.api.android.lib6.gmm6.vector.bz.s(:com.google.android.gms.dynamite_mapsdynamite@221514104@22.15.14 (190800-0):29)
E/AndroidRuntime(17945): at com.google.maps.api.android.lib6.gmm6.vector.bs.b(:com.google.android.gms.dynamite_mapsdynamite@221514104@22.15.14 (190800-0):151)
E/AndroidRuntime(17945): at com.google.maps.api.android.lib6.gmm6.vector.av.run(:com.google.android.gms.dynamite_mapsdynamite@221514104@22.15.14 (190800-0):48)
I/Process (17945): Sending signal. PID: 17945 SIG: 9

@martin-braun
Copy link
Member

@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!

@TouseefAQ
Copy link

TouseefAQ commented Jun 30, 2022

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.

@martin-braun martin-braun self-assigned this Jul 4, 2022
@martin-braun
Copy link
Member

martin-braun commented Jul 4, 2022

@TouseefAQ

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 flutter doctor -v. I need to know if everything looks right as well as the Flutter version you are using.

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.

@mauriziopinotti
Copy link

mauriziopinotti commented Jul 8, 2022

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();

@martin-braun
Copy link
Member

@mauriziopinotti Could you please share the output of flutter doctor -v and tell me on what emulator/device you are testing, including its API and bit architecture?

@mauriziopinotti
Copy link

@mauriziopinotti Could you please share the output of flutter doctor -v and tell me on what emulator/device you are testing, including its API and bit architecture?

Sure, here's the output of flutter doctor:

[✓] Flutter (Channel stable, 3.0.4, on Ubuntu 22.04 LTS 5.15.0-40-generic, locale en_US.UTF-8)
    • Flutter version 3.0.4 at /home/maurix/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 85684f9300 (10 days ago), 2022-06-30 13:22:47 -0700
    • Engine revision 6ba2af10bb
    • Dart version 2.17.5
    • DevTools version 2.12.2

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /home/maurix/Android/Sdk
    • Platform android-33, build-tools 33.0.0
    • ANDROID_HOME = /home/maurix/Android/Sdk
    • Java binary at: /snap/android-studio/123/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • CHROME_EXECUTABLE = /usr/bin/chromium-browser

[✓] Linux toolchain - develop for Linux desktop
    • Ubuntu clang version 14.0.0-1ubuntu1
    • cmake version 3.22.1
    • ninja version 1.10.1
    • pkg-config version 0.29.2

[✓] Android Studio (version 2021.2)
    • Android Studio at /snap/android-studio/123/android-studio
    • Flutter plugin version 69.0.2
    • Dart plugin version 212.5744
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)

[✓] IntelliJ IDEA Ultimate Edition (version 2022.1)
    • IntelliJ at /snap/intellij-idea-ultimate/368
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.69.0)
    • VS Code at /usr/share/code
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (2 available)
    • Linux (desktop) • linux  • linux-x64      • Ubuntu 22.04 LTS 5.15.0-40-generic
    • Chrome (web)    • chrome • web-javascript • Chromium 103.0.5060.53 snap

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

I reproduced the issue on emulator Pixel 4 API 30 Android 11 x86_64 but also on various real devices (Galaxy S21 and others).

@martin-braun
Copy link
Member

martin-braun commented Jul 11, 2022

@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.

@martin-braun
Copy link
Member

martin-braun commented Jul 11, 2022

@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.

@mauriziopinotti
Copy link

@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).

@martin-braun
Copy link
Member

@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.

the issue is only reproducible if you do something with the picked result, if you just ignore the PickResult returned by the dialog the crash does not occur.

You said, over there. Seems weird to me, since our PickResult is part of this repo and not theirs. I out-commented selectedPlace = result; in the callback and still got the crash after 30 tries, you might just had some luck on testing to not catch it, I would remove that comment to prevent any confusion. Simply popping on the callback will cause this issue on rare occasions anyways.

@martin-braun
Copy link
Member

martin-braun commented Jul 11, 2022

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 onMapCreated callback is fired too early, the GoogleMap.OnMapLoadedCallback was never exposed which might call when the initialization is fully complete.

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.

@Wian-TMC
Copy link

Awesome feedback!!!

@martin-braun
Copy link
Member

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.

@martin-braun martin-braun pinned this issue Jul 12, 2022
@martin-braun martin-braun added the state:onhold This issue will be fixed when an external dependency has been updated label Jul 12, 2022
@giorgio79
Copy link

Thx Martin for your efforts. This bug has been killing my app with 3% crash rate. Will try the git repo fix

@giorgio79
Copy link

Looks like Google fixed this bug flutter/flutter#105965 (comment)

It works according to my tests. Wondering about google_maps_place_picker_mb
Do we need to update the pubspec.yaml of this plugin and add the required https://pub.dev/packages/google_maps_flutter_android#map-renderer code to make this plugin work with the fixed version of gmaps?

@martin-braun
Copy link
Member

@giorgio79 I will look into this.

@martin-braun
Copy link
Member

@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 martin-braun removed the state:onhold This issue will be fixed when an external dependency has been updated label Dec 22, 2022
@martin-braun martin-braun unpinned this issue Apr 26, 2023
@canibal1
Copy link

@martin-braun 3.0.2 still in version. When the map is opened and then quickly closed, it gives the error here.

@martin-braun
Copy link
Member

@canibal1 Please upgrade to 3.1.1 my friend.

@canibal1
Copy link

@martin-braun
Thank you for reply,
There is an issue witj upgrading to 3.1.1 because of this dependcy error.

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.
And because google_maps_place_picker_mb >=2.0.0-mb.14 depends on google_maps_webservice ^0.0.20-nullsafety.5, google_maps_place_picker_mb >=2.0.0-mb.14 requires http ^0.13.0.
So, because exampleapp depends on both google_maps_place_picker_mb 3.1.1 and http 1.1.0, version solving failed.

@martin-braun
Copy link
Member

martin-braun commented Jul 18, 2023

@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.

@canibal1
Copy link

@martin-braun
I did as you said and still the app crashes.
Screenshot 2023-07-18 at 19 28 05

Screenshot 2023-07-18 at 19 27 14

@martin-braun
Copy link
Member

martin-braun commented Jul 18, 2023

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 martin-braun pinned this issue Jul 18, 2023
@canibal1
Copy link

canibal1 commented Aug 3, 2023

@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!!!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type:bug This is a bug that needs to be fixed
Projects
None yet
Development

No branches or pull requests

8 participants