nodefourtytwo / gnome-shell-extension-cpu-freq

Change CPU frequency from gnome shell
12 stars 11 forks source link

Extension start error : Expected type utf8 for Argument 'text' but got type 'undefined' (nil) #20

Open ftoral opened 10 years ago

ftoral commented 10 years ago

Hello,

i try to run the extension on my system, but it can't start because of an error :

JS LOG: Extension "cpufreq@nodefourtytwo.net" had error: Error: Expected type utf8 for Argument 'text' but got type 'undefined' (nil)

No more information in the log, i don't know how to get the line number... I'm running Debian Jessie and GNOME Shell 3.8.4

Any idea ?

blind-coder commented 10 years ago

I have the same problem and tracked it down somewhat. This happens because cpufreq-info -fm returns nothing, yielding a return value of 234. This is because: open("/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq", O_RDONLY) = -1 ENOENT (No such file or directory) That node disappears with CONFIG_X86_INTEL_PSTATE (see http://linux-kernel.2935.n7.nabble.com/CONFIG-X86-INTEL-PSTATE-disables-CPU-frequency-transition-stats-many-governors-and-other-standard-fes-td641074.html) You can somewhat bypass that with this fix, but it still will not work:

diff --git a/extension.js b/extension.js
index 972b975..02de5a8 100644
--- a/extension.js
+++ b/extension.js
@@ -120,7 +120,9 @@ CpuFreq.prototype = {
                 if(cpufreq_output[0]) freqInfo = cpufreq_output[1].toString().split("\n", 1)[0];
                 if (freqInfo){
                     this.title=freqInfo;
-                }
+                } else {
+                                                                       this.title="!";
+                                                               }
             }

             if (this.cpuPowerPath){
@@ -128,7 +130,9 @@ CpuFreq.prototype = {
                 if(cpupower_output[0]) freqInfo = cpupower_output[1].toString().split("\n")[1];
                 if (freqInfo){
                     this.title=freqInfo;
-                }
+                } else {
+                                                                       this.title="!";
+                                                               }
             }
         }
         else{
nodefourtytwo commented 10 years ago

Hi! thanks for the debug!

Would you mind sending a pull request?

blind-coder commented 10 years ago

For a four line change? Sorry, but: Yes.

ftoral commented 10 years ago

Hi, thanks @blind-coder could you please explain how and with what tools you tracked this ?

ftoral commented 10 years ago

Oops ! was closed unintentionally, bad button, sorry !

blind-coder commented 10 years ago

I looked at what commands the script was calling and what it expected to receive from them. Then I called the command myself and checked the output. When I saw that it returned an empty string and a return code 234 I used strace to track down what it tried to do and where it failed. Then I saw that: open("/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq", O_RDONLY) = -1 ENOENT (No such file or directory) and just asked google why that file might be missing, leading me to the page linked above.