Sometimes this error shows up in logs. After digging out more, I found that it happens when RILNetworkInterface is disconnected and then gets unregistered from NetworkManager very quickly. I was able to reproduce this by switching APNs on emulator-x86-kk. The reason is because NetworkManager's processes DISCONNECTED event step by step (using promise), so when setAndConfigureActive() is finally called, it access |_activeNetwork| which holds a reference to the network interface that is already unregistered and shutdown by DataCallManager. I'm still thinking a good way to solve this, suggestions are welcome.
Created attachment 8679209 [details] [diff] [review] [WIP] patch. To solve this, I propose to let NetworkManager maintain an internal object that contains information of each 'networkInterface'. In this way, NetworkManager will have full control over this internal object, hence can do the stuff it needs to do (adding routes, setting dns, fire events, etc) asynchronously, without being worried about 'networkInterface' modified by outer modules.