nw.js icon indicating copy to clipboard operation
nw.js copied to clipboard

chrome.fileSystem.chooseEntry takes so long to show the dialog

Open uygarbayer opened this issue 10 years ago • 6 comments

I'm using chrome.fileSystem.chooseEntry on v0.13.0-beta3-linux-x64 to open a file system dialog, but it is taking like 20 seconds for the dialog to appear. Why does it take so long?

Here is a demo project

demo.zip

uygarbayer avatar Jan 14 '16 18:01 uygarbayer

Do you have autofs or something? By default it starts with /home dir, maybe you have it (or subfolders) network-mounted? Try to pick /tmp the first time and pay attention to timeout when calling it again (it should open on last position, the /tmp usually not containing any mounts in it's subtree). This could be related to your filesystem lag, not chromium. I've tried your demo on Ubuntu 14.04.3 LTS with same nwjs version you reported, it behaves fine.

offshore avatar Jan 14 '16 18:01 offshore

I don't have autofs, I have Ubuntu 14.04.3 LTS on an ssd. This is not a problem when I try the same thing with google chrome app/extensions. It only happens in nw.js. I tried with suggestedName:"/tmp" option and nothing changed. By the way, at first try it takes like 20 seconds but closing and re-opening the file dialog works instantly, so I guess there is a some sort of cache mechanism there.

I'm not so familiar with nw.js and this is actually my first try, would it be about the way I run it? I unzipped nwjs-sdk-v0.13.0-beta3-linux-x64.tar.gz binaries and here is how I am using it;

  • Go into unzipped nwjs-sdk-v0.13.0-beta3-linux-x64 directory through console
  • Run the following command: ./nw /home/uza/demo
  • /home/uza/demo has package.json and other files.

uygarbayer avatar Jan 14 '16 20:01 uygarbayer

Well, okay. Rmdir /home/uza/.config/demo or change name in package.json to something different (e.g. demo2); this will force the whole thing to run from scratch and nothing will be based on previous runs and actions. Open terminal and go to your nwjs-sdk-v0.13.0-beta3-linux-x64 directory. Run: strace -c ./nw /home/uza/demo click on that-opening-dialog-control, pick /tmp there and hit open, close app after that as usual. Now you have nice table with aggregated timings and counts for system calls performed by nw while it was running your app. Feel free to share with us, it does not contain any sensitive info when used like above. Normally you should see that most time were spent on poll (guess, why :)) and recvmsg (mainly for ipc) calls. For your case, if the problem is NOT related to nw, but to your filesystem, you should see something like statfs, fstatfs, stat, access, etc is wasting time.

offshore avatar Jan 14 '16 23:01 offshore

Well, when I run the app as you described after removing the file under .config and changing its name to something else it worked beautifully without any problems, I also noticed that I had a fake cd drive under /media/ and CDemu for a virtual cd drive, I also removed those and after a reboot it worked perfectly, so I'm guessing that it was a problem with my previous settings and actions. Now I can use my previously written chrome.fileSystem code without any mods. I'm new to node.js and nw.js and I appreciate the help, thank you :) Here is the table that you asked (I think it looks exactly as you described)

% time seconds usecs/call calls errors syscall


80.08 0.020137 5 4178 poll 13.52 0.003399 3 1059 39 futex 4.89 0.001229 44 28 clone 0.56 0.000142 0 10832 9376 recvmsg 0.49 0.000123 0 967 writev 0.15 0.000037 0 256 mprotect 0.14 0.000036 0 760 write 0.09 0.000022 0 872 247 open 0.04 0.000011 0 709 close 0.04 0.000010 0 529 fstat 0.00 0.000000 0 1306 22 read 0.00 0.000000 0 1192 893 stat 0.00 0.000000 0 108 11 lstat 0.00 0.000000 0 131 lseek 0.00 0.000000 0 552 mmap 0.00 0.000000 0 196 munmap 0.00 0.000000 0 1 brk 0.00 0.000000 0 32 rt_sigaction 0.00 0.000000 0 6 rt_sigprocmask 0.00 0.000000 0 1 1 rt_sigreturn 0.00 0.000000 0 1 pwrite 0.00 0.000000 0 348 236 access 0.00 0.000000 0 4 pipe 0.00 0.000000 0 256 madvise 0.00 0.000000 0 4 shmget 0.00 0.000000 0 4 shmat 0.00 0.000000 0 4 shmctl 0.00 0.000000 0 16 dup 0.00 0.000000 0 7 socket 0.00 0.000000 0 5 connect 0.00 0.000000 0 19 1 sendto 0.00 0.000000 0 12 3 recvfrom 0.00 0.000000 0 16 sendmsg 0.00 0.000000 0 3 shutdown 0.00 0.000000 0 1 bind 0.00 0.000000 0 1 listen 0.00 0.000000 0 4 getsockname 0.00 0.000000 0 3 getpeername 0.00 0.000000 0 4 socketpair 0.00 0.000000 0 2 setsockopt 0.00 0.000000 0 1 execve 0.00 0.000000 0 1 wait4 0.00 0.000000 0 6 kill 0.00 0.000000 0 17 uname 0.00 0.000000 0 2 shmdt 0.00 0.000000 0 63 1 fcntl 0.00 0.000000 0 2 fsync 0.00 0.000000 0 9 ftruncate 0.00 0.000000 0 68 getdents 0.00 0.000000 0 3 getcwd 0.00 0.000000 0 2 rename 0.00 0.000000 0 5 mkdir 0.00 0.000000 0 2 rmdir 0.00 0.000000 0 3 creat 0.00 0.000000 0 16 2 unlink 0.00 0.000000 0 4 symlink 0.00 0.000000 0 38 6 readlink 0.00 0.000000 0 2 chmod 0.00 0.000000 0 3 getrlimit 0.00 0.000000 0 2 getuid 0.00 0.000000 0 1 geteuid 0.00 0.000000 0 3 getresuid 0.00 0.000000 0 3 getresgid 0.00 0.000000 0 2 sigaltstack 0.00 0.000000 0 5 2 statfs 0.00 0.000000 0 76 fstatfs 0.00 0.000000 0 1 arch_prctl 0.00 0.000000 0 124 gettid 0.00 0.000000 0 1 set_tid_address 0.00 0.000000 0 24 fadvise64 0.00 0.000000 0 1 clock_getres 0.00 0.000000 0 5 1 inotify_add_watch 0.00 0.000000 0 2 inotify_rm_watch 0.00 0.000000 0 131 92 openat 0.00 0.000000 0 1 set_robust_list 0.00 0.000000 0 2 fallocate 0.00 0.000000 0 25 eventfd2 0.00 0.000000 0 1 pipe2 0.00 0.000000 0 1 inotify_init1


100.00 0.025146 25087 10933 total

uygarbayer avatar Jan 14 '16 23:01 uygarbayer

You are welcome.

offshore avatar Jan 14 '16 23:01 offshore

Glad to see your issue solved. :smile:

ghostoy avatar Jan 14 '16 23:01 ghostoy