'Black screen when rendering HERE map in a single-activity architecture
There is a problem when transitioning between two fragments having a MapView inside them - the map on the second fragment is black. The same second fragment works ok, if it is started as the first one. The problem is likely related to mapView.onCreate in the second fragment being called before mapView.onDestroy in the first one - a natural consequence of the fragment lifecycle. I'm using Here maps Explore edition, version 4.4.2.0.2491. Both fragments' code is pretty straightforward:
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
mapView.onCreate(savedInstanceState)
mapView?.mapScene?.loadScene(
MapScheme.NORMAL_DAY
) { errorCode ->
if (errorCode == null) {
mapView.camera.lookAt(MapConfiguration.MAP_INITIAL_GEOCOORDINATES)
} else {
Timber.e("onLoadScene failed: $errorCode")
}
}
}
override fun onDestroyView() {
mapView?.onDestroy()
super.onDestroyView()
}
Warn+ logs when the black screen happens:
2020-07-28 09:07:16.718 1147-1147/com.infullmobile.bioledger W/harp-sdk: [WARN ] harp-sdk - View config is empty. No map content will be displayed until valid config is provided.
2020-07-28 09:07:16.719 1147-1147/com.infullmobile.bioledger W/harp-sdk: [WARN ] harp-sdk - Ignore adding invalid observer
2020-07-28 09:07:16.719 1147-1147/com.infullmobile.bioledger W/harp-sdk: [WARN ] harp-sdk - Ignore adding invalid observer
2020-07-28 09:07:16.719 1147-1147/com.infullmobile.bioledger W/harp-sdk: [WARN ] harp-sdk - Ignore adding invalid observer
2020-07-28 09:07:16.719 1147-1147/com.infullmobile.bioledger W/harp-sdk: [WARN ] harp-sdk - Ignore adding invalid observer
2020-07-28 09:07:16.719 1147-1147/com.infullmobile.bioledger W/harp-sdk: [WARN ] harp-sdk - Ignore adding invalid observer
2020-07-28 09:07:16.721 1147-1612/com.infullmobile.bioledger E/harp-sdk: [ERROR] harp-sdk - Failed to attach RenderTarget to View.
2020-07-28 09:07:16.722 1147-1612/com.infullmobile.bioledger W/harp-sdk: [WARN ] harp-sdk - Invalid render target at initialization time.
2020-07-28 09:07:16.722 1147-1612/com.infullmobile.bioledger W/harp-sdk: [WARN ] harp-sdk - Invalid map configuration at initialization time.
2020-07-28 09:07:16.832 1147-1612/com.infullmobile.bioledger W/libEGL: EGLNativeWindowType 0x7726c76010 disconnect failed
2020-07-28 09:07:16.835 1147-1612/com.infullmobile.bioledger W/magma-style: [WARN ] magma-style - No ISceneObjectStylesSetter instance accepts the style source 'watermark'.
2020-07-28 09:07:16.836 1147-1612/com.infullmobile.bioledger W/magma-style: [WARN ] magma-style - No ISceneObjectStylesSetter instance accepts the style source 'marker3D_layer'.
2020-07-28 09:07:16.836 1147-1612/com.infullmobile.bioledger W/magma-style: [WARN ] magma-style - No ISceneObjectStylesSetter instance accepts the style source 'polyline'.
2020-07-28 09:07:16.837 1147-1612/com.infullmobile.bioledger W/magma-style: [WARN ] magma-style - No ISceneObjectStylesSetter instance accepts the style source 'selection_polygons'.
2020-07-28 09:07:16.837 1147-1612/com.infullmobile.bioledger W/magma-style: [WARN ] magma-style - No ISceneObjectStylesSetter instance accepts the style source 'marker_layer'.
Correct warn+ logs from the same fragment (when started as first):
2020-07-28 09:08:27.936 1147-1147/com.infullmobile.bioledger W/harp-sdk: [WARN ] harp-sdk - View config is empty. No map content will be displayed until valid config is provided.
2020-07-28 09:08:27.937 1147-1147/com.infullmobile.bioledger W/harp-sdk: [WARN ] harp-sdk - Ignore adding invalid observer
2020-07-28 09:08:27.937 1147-1147/com.infullmobile.bioledger W/harp-sdk: [WARN ] harp-sdk - Ignore adding invalid observer
2020-07-28 09:08:27.937 1147-1147/com.infullmobile.bioledger W/harp-sdk: [WARN ] harp-sdk - Ignore adding invalid observer
2020-07-28 09:08:27.937 1147-1147/com.infullmobile.bioledger W/harp-sdk: [WARN ] harp-sdk - Ignore adding invalid observer
2020-07-28 09:08:27.937 1147-1147/com.infullmobile.bioledger W/harp-sdk: [WARN ] harp-sdk - Ignore adding invalid observer
2020-07-28 09:08:27.937 1147-1612/com.infullmobile.bioledger E/harp-sdk: [ERROR] harp-sdk - Failed to attach RenderTarget to View.
2020-07-28 09:08:27.938 1147-1612/com.infullmobile.bioledger W/harp-sdk: [WARN ] harp-sdk - Invalid render target at initialization time.
2020-07-28 09:08:27.938 1147-1612/com.infullmobile.bioledger W/harp-sdk: [WARN ] harp-sdk - Invalid map configuration at initialization time.
2020-07-28 09:08:28.175 1147-1612/com.infullmobile.bioledger W/magma-config: [WARN ] magma-config - Couldn't find a scene object or scene extension factory registered under the name 'geojson.polylines'
2020-07-28 09:08:28.175 1147-1612/com.infullmobile.bioledger W/magma-config: [WARN ] magma-config - Couldn't find a scene object or scene extension factory registered under the name 'geojson.polylines'
2020-07-28 09:08:28.419 1147-1612/com.infullmobile.bioledger E/CL_magma: [ERROR] CL_magma - Couldn't find font file 'fonts/NotoSansKhmer-Regular-unhinted.ttf'
2020-07-28 09:08:28.419 1147-1612/com.infullmobile.bioledger E/CL_magma: [ERROR] CL_magma - Couldn't find font file 'fonts/NotoSansMyanmar-Regular-unhinted.ttf'
And the resulting black map:
Solution 1:[1]
It looks like you try to re-use the same mapView instance field? Since the Explore Edition supports multiple mapView instances (usable on the same view, at the same time), maybe you can try to use two separate instances. Then you don't get trouble when an instance is destroyed, as the other one remains intact.
Solution 2:[2]
i had the same issue, and i figured out that what was missing was adding those methods in myy activity:
@Override
protected void onPause() {
super.onPause();
mapView.onPause();
}
@Override
protected void onResume() {
super.onResume();
mapView.onResume();
}
@Override
protected void onDestroy() {
super.onDestroy();
mapView.onDestroy();
}
after that it all worked all just fine :D
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Nusatad |
| Solution 2 | Victor Pierre |

