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

libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x63808001102f10d7 in tid 13696 (FinalizerDaemon) #767

Closed
nouman1nv opened this issue Nov 12, 2018 · 5 comments

Comments

@nouman1nv
Copy link

nouman1nv commented Nov 12, 2018

mapbox through exception Fatal Signal 11
I have a fragment which contain MapView. On first time the MapView loads and every things is perfectly good but when i go to next fragment and then comeback to my oldFragment the code certainly through an exception libc: Fatal Signal 11 i am using version 6.7.0 and using locationComponent api
Can some one please suggest me some things

@nouman1nv
Copy link
Author

nouman1nv commented Nov 12, 2018

class MyFragment() : Fragment(), OnMapReadyCallback {
    private lateinit var mapView: MapView
    private lateinit var map: MapboxMap

 private lateinit var locationComponent: LocationComponent
    private lateinit var permissionsManager: PermissionsManager
  override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        binding = DataBindingUtil.inflate<ViewDataBinding>(inflater, R.layout.layout_my_fragment, container, false)

        mapView = binding.root.myMainMap
 mapView?.onCreate(savedInstanceState)
           mapView?.getMapAsync(this)

    return binding.root
    }


    companion object {
        fun newInstance() = MyFragment()
    }

override fun onMapReady(mapboxMap: MapboxMap?) {
        if (mapboxMap != null) {
            map = mapboxMap!!
            locationComponent = mapboxMap?.locationComponent
           locationEnable()



        }
    }
@SuppressLint("MissingPermission")
    fun locationEnable() {
        if (PermissionsManager.areLocationPermissionsGranted(activity as HomeActivity)) {
            if (context != null) {
                locationComponent?.activateLocationComponent(context!!)
                locationComponent.isLocationComponentEnabled = true
                locationComponent.renderMode = RenderMode.COMPASS
            }

            var lastLocation = locationComponent.locationEngine?.lastLocation;
            if (lastLocation != null) {

                setCamerpostion(lastLocation);
            } else {
                locationComponent.locationEngine?.addLocationEngineListener(object : LocationEngineListener {
                    override fun onConnected() {

                    }

                    override fun onLocationChanged(location: Location?) {
                        if (location != null) {
                            setCamerpostion(location);
                        }

                    }
                })
            }
     
        } else {


            (activity as HomeActivity).requestPermissions(Manifest.permission.ACCESS_FINE_LOCATION, object : PermissionCallBack {
                override fun permissionGranted() {
                    super.permissionGranted()
                    locationEnable()
                }

                override fun permissionDenied() {
                    super.permissionDenied()
                    locationEnable()
                }

            })
        }
    }
 fun setCamerpostion(camerpostion: Location) {
        map.animateCamera(CameraUpdateFactory.newLatLngZoom(LatLng(camerpostion.latitude, camerpostion.longitude), 100.0));
    }


    override fun onStart() {
        super.onStart();
        mapView?.onStart();

    }


    override fun onPause() {
        super.onPause();
        mapView?.onPause();
    }

    override fun onStop() {
        super.onStop();
        mapView?.onStop();
    }

    override fun onLowMemory() {
        super.onLowMemory();
        mapView?.onLowMemory();
    }

    override fun onDestroy() {
        super.onDestroy();
        mapView?.onDestroy();
    }


    override fun onResume() {
        super.onResume()
       
        mapView?.onResume()
    }


    override fun onSaveInstanceState(outState: Bundle) {
        super.onSaveInstanceState(outState)
        mapView?.onSaveInstanceState(outState)
    }
}

@arnekaiser
Copy link
Contributor

In a fragment you have to call the lifecycle methods in onCreateView() and in onDestroyView(). See https://github.com/mapbox/mapbox-gl-native/blob/master/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapFragment.java

@LukasPaczos
Copy link
Contributor

LukasPaczos commented Nov 12, 2018

Thanks for reaching out @nouman1nv, and thanks for jumping in @arnekaiser! And to confirm - yes, you need to call MapView#onCreate from fragment's onCreateView() and MapView#onDestroy from fragment's onDestroyView().

@nouman1nv
Copy link
Author

nouman1nv commented Nov 13, 2018

thank you very much @LukasPaczos and @arnekaiser
i have one another issue i am displaying mapbox in recyclevie which through an exception
A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 5230 (FinalizerDaemon)
how to manage lifecycle in recycleview

@LukasPaczos
Copy link
Contributor

A general rule is that you need to follow the view lifecycle inside of the recycler rather than activity/fragment's lifecycle when calling MapView's lifecycle methods. So, whenever a view is recycled, you need to call onPause, onStop and onDestroy. Then, reverse the process for when the view is created.

You can also check out the POC in mapbox/mapbox-gl-native#13132.

Closing as not-actionable from plugins perspective.

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

3 participants