Skip to content

Get rid of MapboxGlPlatform.getInstance - #710

Merged
shroff merged 1 commit into
masterfrom
platform-getinstance
Oct 24, 2021
Merged

shroff merged 1 commit into
masterfrom
platform-getinstance

Conversation

@shroff

@shroff shroff commented Oct 9, 2021

Copy link
Copy Markdown
Collaborator

This was an unnecessary layer of indirection, potentially causing a memory leak by holding on to the platform instance.

@shroff
shroff force-pushed the platform-getinstance branch from 5dc4e29 to db64074 Compare October 9, 2021 18:38
@shroff
shroff had a problem deploying to ANDROID_CI_DOWNLOADS_TOKEN October 9, 2021 18:38 Failure
@shroff
shroff had a problem deploying to ANDROID_CI_DOWNLOADS_TOKEN October 9, 2021 18:38 Failure
@felix-ht

felix-ht commented Oct 15, 2021 •

Copy link
Copy Markdown
Collaborator

Might there be any reason to hold onto more than one platform instance?

Could this cause issues if multiple maps are shown at the same time?

@felix-ht

felix-ht commented Oct 15, 2021 •

Copy link
Copy Markdown
Collaborator

@shroff i checked and and we need multiple MapboxGlPlatforms to support multiple simultaneous maps. For example it tracks the callbacks and those need to be different for different instances. So going with the dispose approach of @aaverin seems like the way to go!

Well i got it wrong as you still create a new instance of MapboxGlPlatform for each new MapboxMap. So this is fine! LGTM

@tonnyavery

Copy link
Copy Markdown
Contributor

PR looks good to me too, I just didn't yet have the time to test if it resolves the leaks completely.
You are welcome to merge, I can only do the testing end of next week.

@felix-ht

Copy link
Copy Markdown
Collaborator

@aaverin it would be great if you could check it out and post your results

@tonnyavery

Copy link
Copy Markdown
Contributor

Pointing to this branch directly, I can still see many instances of MapboxMap sitting in memory when there shouldn't be any. Probably the solution would be a combination of #706 and this.
I will try to merge this PR into #706 and clean it up

@tonnyavery tonnyavery mentioned this pull request Oct 21, 2021
@tonnyavery

Copy link
Copy Markdown
Contributor

I have merged this PR into #706 and added some more fixes for memory leaks on the top. If #706 is merged this PR can be closed.

@shroff
shroff merged commit b28e8c6 into master Oct 24, 2021
@shroff
shroff deleted the platform-getinstance branch October 24, 2021 17:09
m0nac0 added a commit to maplibre/flutter-maplibre-gl that referenced this pull request May 13, 2022
* 710 (Get rid of MapboxGlPlatform.getInstance) flutter-mapbox-gl/maps#710
* 852( Android embedding fixes - migrate to maven) flutter-mapbox-gl/maps#852 was also required to fix compile time errors
* a small fix for the platform dependency
* Update CI flutter version
* cherry-pick upstream#904 (fix android build issues)

Co-authored-by: shroff <[email protected]>
Co-authored-by: Felix Horvat <[email protected]>

This branch had an error being deployed

1 failed deployment
ANDROID_CI_DOWNLOADS_TOKEN — db640744 Deployed Oct 9, 2021 by shroff
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

Successfully merging this pull request may close these issues.

3 participants