Skip to content
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

Calling easeTo may be creating a memory leak #809

Open
adambeer opened this issue Dec 12, 2024 · 0 comments
Open

Calling easeTo may be creating a memory leak #809

adambeer opened this issue Dec 12, 2024 · 0 comments

Comments

@adambeer
Copy link

adambeer commented Dec 12, 2024

I have a handful of buttons on top of my Mapbox map that perform various functions with the map. One of them is a "3D view toggle". This function just calls easeTo. Im getting some strange behaviour after interacting with this button that I dont get at all if I dont touch it. Ive attached the code were using as well as a video of what this issue looks like.

Mapbox SDK Version: Seems to be all
Testing on iOS

void _togglePitch() {
    // Prevent multiple simultaneous pitch changes
    if (_isEasingInProgress) {
      return;
    }

    // Ensures mapboxMap is not null before attempting to use it
    if (mapboxMap == null) {
      debugPrint('MapboxMap is not initialized');
      return;
    }

    try {
      // Set flag to prevent additional calls
      setState(() {
        _isEasingInProgress = true;
        is3D = !is3D;
      });

      mapboxMap!.easeTo(
        CameraOptions(pitch: is3D ? 75 : 0),
        MapAnimationOptions(duration: 1000),
      ).then((_) {
        // Reset the flag when animation is complete
        setState(() {
          _isEasingInProgress = false;
        });
      }).catchError((error) {
        debugPrint('Error toggling pitch: $error');
        setState(() {
          is3D = !is3D;
          _isEasingInProgress = false;
        });
      });
    } catch (e) {
      debugPrint('Error toggling pitch: $e');
        // Optionally, reverts the state if the pitch change fails
      setState(() {
        is3D = !is3D;
        _isEasingInProgress = false;
      });
    }
  }
ScreenRecording_12-11-2024.17-17-00_1.mov

IMG_4938

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant