flutter-mapbox-gl / maps

A Mapbox GL flutter package for creating custom maps
Other
1.04k stars 503 forks source link

Revert "Workaround for disposal crash with flutter3 (#1172)" #1212

Closed felix-ht closed 1 year ago

felix-ht commented 1 year ago

This reverts commit 2ebb7a53ccfc77a852becba1260146902b7fb835.

I decided to revert this merge commit as it causes issues with old flutter versions - apparently the interface of TextureAndroidViewController changed - this causes the version post this commit to no longer build for flutter 2.X

Might be tricky to get this working for 2.x and 3.x.

I guess that we could use introspection to call the right method?

dawid-niedzwiecki commented 1 year ago

Please don't merge that.

AAverin commented 1 year ago

we can still keep the workaround as a separate branch @dawid-niedzwiecki any reason not to merge?

srmncnk commented 1 year ago

I guess that we could use introspection to call the right method?

Can be done. Is as ugly as swizzling on iOS, but on the other hand, that would allow us to know on which flutter version we run. I would need an evening of two to make this work, I suggest we leave this open and make an effort to try and fix it.

Basically make this workaround work with reflection / introspection and, if detected that we don't run on flutter 3.x.x, don't use the workaround.

srmncnk commented 1 year ago

Looked into this and I must admit that I falsely saw this to be an Java/Kotlin issue. Since this is breaking the Flutter API, we would have to use introspection / reflection there. AFAIK 'dart:mirrors' is not supported on flutter and using reflectable with code generation probably wouldn't work on flutter API classes as well?

I was however able to somewhat unify flutter2 and flutter3 API in a way that it doesn't break behaviour, doesn't leak resources and still compiles for both SDKs. I tested with 2.10.5 and 3.3.5. It's a bit lucky. See this PR: https://github.com/flutter-mapbox-gl/maps/pull/1217

felix-ht commented 1 year ago

closed in favor of https://github.com/flutter-mapbox-gl/maps/pull/1217