-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Conversation
4b2720c
to
774ab89
Compare
@@ -81,8 +81,6 @@ class NativeMapView : public View, public Backend { | |||
|
|||
// JNI // | |||
|
|||
void destroy(jni::JNIEnv&); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was unused, we are using the destructor of native_map_view for this
@@ -73,6 +55,9 @@ NativeMapView::NativeMapView(jni::JNIEnv& _env, | |||
pixelRatio, mbgl::android::FileSource::getDefaultFileSource(_env, jFileSource), *threadPool, | |||
MapMode::Continuous, GLContextMode::Unique, ConstrainMode::HeightOnly, | |||
ViewportMode::Default, jni::Make<std::string>(_env, _programCacheDir)); | |||
|
|||
_initializeDisplay(); | |||
_initializeContext(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
current codebase always requires to have one map object for one display/context. This is now consolidated in the constructor of the map object. This as a result removes NativeMapView::initializeDisplay
, NativeMapView::terminateDisplay
, ....
@@ -57,9 +56,6 @@ | |||
// Device density | |||
private final float pixelRatio; | |||
|
|||
// Listeners for Map change events | |||
private CopyOnWriteArrayList<MapView.OnMapChangedListener> onMapChangedListeners; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
postponing map creation requires to manage OnMapChangeListeners in MapView.java instead.
this.mapboxMap = mapboxMap; | ||
} | ||
|
||
@Override | ||
public void onMapChanged(@MapChange int change) { | ||
if (change == DID_FINISH_LOADING_STYLE && initialLoad) { | ||
initialLoad = false; | ||
new Handler().post(new Runnable() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this resolves a memory leak when quickly rotating the device on map start.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does change the timing of the event a little though. The handler ensured that it was fired after the current loop cycle. Not sure if that is a big deal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
afaik, we posted to the end of message queue to make sure the view was measured (to be able to initialize all components with correct width/height) . Now with this PR, we postpone map creation and thus style loading to after onResume (when the view is toggled visible). Can't really think of another reason why we needed that post there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. Just noting. As long as the tests succeed it shouldn't be a big deal.
@@ -384,7 +391,10 @@ public void setStyleUrl(@NonNull String url) { | |||
if (destroyed) { | |||
return; | |||
} | |||
|
|||
if (nativeMapView == null) { | |||
mapboxMapOptions.styleUrl(url); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keeping state in mapboxMapOptions is map isn't ready yet, this will be applied to the map when started later on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are quite a few unrelated changes in this pr (removing #includes). Could you separate those if they are intentional?
774ab89
to
b4aebb5
Compare
58a9746
to
96c11f4
Compare
96c11f4
to
d52030c
Compare
I removed the cpp cleanup from this PR |
@@ -86,6 +86,10 @@ NativeMapView::NativeMapView(jni::JNIEnv& _env, | |||
static_cast<uint32_t>(height) }, pixelRatio, | |||
fileSource, *threadPool, MapMode::Continuous, | |||
ConstrainMode::HeightOnly, ViewportMode::Default); | |||
|
|||
// initialize egl components | |||
_initializeDisplay(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only problem I see here is that when we move to rendering on a separate thread, these should probably not be called from the main thread. But we can adjust to that lateron.
This PR rewrites the way we do map initialisation. Before this PR we created the map object when the hosting MapView was inflated. This PR now postpones creating the map object until the Surface of the MapView is ready. A benefit of this is that the view will be measured by the time that MapboxMap will be created and thus removes the necessity of posting the OnMapReadyCallback invocations.
Closes #9136