hedayaty / NetSpeed

An extension for gnome 3 to show internet speed
264 stars 83 forks source link

"JS ERROR: TypeError: nm_dev is null" for CDC MBIM Mobile Broadband modem breaks extension #143

Open szpak opened 2 years ago

szpak commented 2 years ago

After the first installation on Dell Latitude, the extension starts, but shows no interfaces, just "---' instead of speed. In the Gnome Shell logs there is:

gnome-shell[3101]: JS ERROR: TypeError: nm_dev is null
                   _retrieve_wifi_ssid@/usr/share/gnome-shell/extensions/netspeed@hedayaty.gmail.com/net_speed.js:458:13
                   _create_menu@/usr/share/gnome-shell/extensions/netspeed@hedayaty.gmail.com/net_speed.js:168:34
                   _update@/usr/share/gnome-shell/extensions/netspeed@hedayaty.gmail.com/net_speed.js:272:18

I've checked it, and the problem is caused by an interface wwp0s20f0u4c2 (renamed from wwan0) for a CDC MBIM Mobile Broadband modem (registered by the cdc_mbim driver) which doesn't have an inserted mobile card (didn't check with).

For some reasons let nm_dev = this._client.get_device_by_iface(iface); returns null which causes a null dereference.

ip reports it as:

2: wwp0s20f0u4c2: <BROADCAST,MULTICAST,NOARP> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether XX:XX:XX:XX:XX:XX brd ff:ff:ff:ff:ff:ff

It might be a problem with the NetworkManager client or its desired behavior - you know it better. Assuming the later nm_dev != null fixes the problem. In the first case, it might be also reported to the NM client team.

Gnome 41.1, gnome-shell-extension-netspeed-3.32-0.1.20211102git8638073.fc35.noarch

szpak commented 2 years ago

After upgrading to gnome-shell-extension-netspeed-3.32-0.4.20220421git5a96082.fc35.noarch I had to re-apply the workaround.

@hedayaty Are you ok with the PR changing:

    _retrieve_wifi_ssid(iface) {
        let nm_dev = this._client.get_device_by_iface(iface);
        if (nm_dev.get_device_type() == NetworkManager.DeviceType.WIFI) {
            let active_ap = nm_dev.get_active_access_point();
            if (active_ap != null) {
                return ByteArray.toString(ByteArray.fromGBytes(active_ap.get_ssid()), 'UTF-8');
            }
        }
        return null;
    }

to:

    _retrieve_wifi_ssid(iface) {
        let nm_dev = this._client.get_device_by_iface(iface);
        if (nm_dev != null && nm_dev.get_device_type() == NetworkManager.DeviceType.WIFI) {
        ...

Or you would like to explain the original reason with the NM team?