2

When I first use the plotting functions (for example, plot(1,1)), Octave hangs for a few minutes. The second and subsequent calls for the same functions are performed quite quickly. The same behavior is repeated the next time you start Octave. I used Octave 4.2.1 with both qt graphics_toolkit and gnuplot graphics_toolkit. Operating system was Windows 7 and 10. I used standart Octave Installer.

How to solve this problem?

SergV
  • 1,269
  • 8
  • 20

1 Answers1

2

This problem is quite common. See for example - Cannot use Octave 4.0.0 graphics toolkit functions or Plot doesn't work in Octave 4.0.0 But I did not find any solutions for this problem. So I made my own investigation.

I ran the well-known utility process-explorer when Octave was hanging up, and I saw that Octave opens all the files in the Windows fonts folder (c:\Windows\Fonts). The size of this folder on my computer is about 400 MByte! I search google and found, that Octave can use font's cache. There is special utility and script file for creating font's cache (see comment to bug). So solution for this problem is quite simple:

  1. Go to Octave folder (c:\Octave\Octave-4.2.1\ on my computer)
  2. Run script - fc_update.bat
  3. Start Octave and check, that there is not any hang or freeze on first call of plotting functions.

There is a log of two sequential starts of this script:

c:\Octave\Octave-4.2.1>fc_update.bat
"Updating fc-cache (may take a while) ..."
C:/WINDOWS/fonts: caching, new cache contents: 1012 fonts, 0 dirs
C:/WINDOWS/fonts: failed to write cache
C:/Users/Sergey/.local/share/fonts: skipping, no such directory
C:/Users/Sergey/.fonts: skipping, no such directory
C:/Users/Sergey/AppData/Local/fontconfig/cache: cleaning cache directory
C:/Users/Sergey/.cache/fontconfig: not cleaning non-existent cache directory
C:/Users/Sergey/.fontconfig: cleaning cache directory
c:\Octave\Octave-4.2.1\bin\fc-cache.exe: failed
"Done."

c:\Octave\Octave-4.2.1>fc_update.bat
"Updating fc-cache (may take a while) ..."
C:/WINDOWS/fonts: skipping, existing cache is valid: 1012 fonts, 0 dirs
C:/Users/Sergey/.local/share/fonts: skipping, no such directory
C:/Users/Sergey/.fonts: skipping, no such directory
C:/Users/Sergey/AppData/Local/fontconfig/cache: cleaning cache directory
C:/Users/Sergey/.cache/fontconfig: not cleaning non-existent cache directory
C:/Users/Sergey/.fontconfig: cleaning cache directory
c:\Octave\Octave-4.2.1\bin\fc-cache.exe: succeeded
"Done."

I think you need to run this script when installing Octave or adding new fonts to the system. I do not understand why this information is not contained in the Octave documentation in a clear and accessible way.

SergV
  • 1,269
  • 8
  • 20
  • The windows installer runs font-config update. You are not even mentioning in your question if you are using the Installer or the portable .zip. Your listing above doesn't make sense: The first run shows that fc update wasn't able to write the cache (It would be important here why, insufficient permissions I guess). your second listing shows, that there is already a cache so the must be a successful run between those two – Andy Jan 14 '18 at 09:20
  • @Andy. I installed Octave 4.2.1 almost a year ago by installer. I have 2 computer with Octave. First - with Windows 7. Second with Windows 10 (2 OS big update after installation of Octave). The solution works for all this computers. About log listing - I ran script 2 time in 1 second interval between this run. There is not any problem with permission - cache folder is created in my user profile folder (C:/Users/Sergey/AppData/Local/fontconfig/cache). May be there is some bug with fc_cache.exe, but running this script twice time resolve problem in any time – SergV Jan 14 '18 at 09:40
  • @Andy I add information about Installer in my question. Thanks. – SergV Jan 14 '18 at 09:45
  • SergV, you should be more specific when exactly the cache is built in your case and when not. Your answer is just a workaround, not a solution because something is blocking fonctconfig cache from writing the cache (perhaps some antivirus?) No developer was able to see this behaviour on his system. Furthermore the cache also is built when actually running the Octave GUI. In your initial question you write "The same behavior is repeated the next time you start Octave." which also looks like there is a problem with write permissions. Are you running fc_update.bat as admin? – Andy Jan 14 '18 at 12:15
  • @Andy. Yes, it is workaround of very common problem. My answer is not bug report to bug list of Octave. So my answer does not contain a lot of information, which is needed for good bug report. If you Octave developer I am ready discuss with you any additional information in private. And I do not understand why you downvote my answer. – SergV Jan 14 '18 at 12:39