I'm tasked with upgrading a lot of legacy models and scripts made in an older version of Matlab/Simulink and have it running smoothly in R2018b. Among other requirements I'm not allowed to have any warnings issued upon execution of .m scripts or Simulink models. This is generally tedious but straightforward to comply.
However, there is a specific warning that Matlab does not give me hints on possible sources:
Warning: MATLAB has disabled some advanced graphics rendering features by switching to software OpenGL. For more information click here.
The link opens the Matlab Help page titled Resolving Low-Level Graphics Issues, which describes issues I'm not finding (or at least not noticing)
I do note that many scripts I run create and close figures, but this is done procedurally. I haven't been able to associate this warning with some specific function or feature. I'm working on a Windows Server machine.
Does anyone have an idea of how to narrow down which kind of function os Simulink block could cause this warning?
As datenwolf and Ander point out, the first thing to try is to update your drivers. If this doesn't work, and your only problem is that you're getting the warning but your graphics still render fine, then you have two other options to try.
First, you can simply modify your OpenGL rendering preferences using opengl. The following will set your preference to 'software' and save that setting for future sessions:
opengl('save', 'software');
Alternatively, you can just try to suppress that particular warning message. After you get the warning, issue this call to the warning function:
w = warning('query', 'last');
The w.identifier field will give you the ID for the warning message, which I believe will be 'MATLAB:hg:AutoSoftwareOpenGL' in this case. You can then add the following line to your startup.m file so that this warning is suppressed every time MATLAB is opened:
warning('off', 'MATLAB:hg:AutoSoftwareOpenGL');
Install the original vendor drivers for your GPU. The drivers that are installed by Windows by default lack full OpenGL support. Download the driver package directly from the website of Intel, AMD or NVidia, depending on what GPU you have.
If you don't have GPU, for example when running in a Virtual Machine, then you can not avoid that warning, because then Matlab has no other choice than falling back on the software OpenGL implementation that it ships with.
There's nothing you can do about that, other than making sure, that the system you're running Matlab on, does have proper OpenGL support!
It took me a long time to get it, so I'll put you here in case it helps how I managed to activate openGL in Linux:
If you haven't already (it's common for other problems), rename libstdc++ library from MATLAB:
mv _YOUR_MATLAB_ROOT_FOLDER_/sys/os/glnxa64/libstdc++.so.6 _YOUR_MATLAB_ROOT_FOLDER_/sys/os/glnxa64/libstdc++.so.6.bak
Create this link: sudo ln -s /usr/lib/x86_64-linux-gnu/dri/ /usr/lib/
Run export MESA_LOADER_DRIVER_OVERRIDE=YOUR_DRI_DRIVER;matlab -desktop -nosoftwareopeng
Your DRI Driver will be a file from /usr/lib/dri, removing "_dri" (in my case was the "radeons" driver for an AMD Vega graphic card.
Run MATLAB from a terminal using: export MESA_LOADER_DRIVER_OVERRIDE=_YOUR_DRIVER_HERE_;matlab -desktop -nosoftwareopengl. YOUR_DRIVER_HERE should be your driver, radeonsi in my case.
Check openGL with info = rendererinfo
If something went wrong, you will be able to see in the terminal which library was responsible. Executing 4) and 5) I was discovering what I had to correct, you can do the same if you have another problem that has not appeared to me.
So that it always runs correctly I put export MESA_LOADER_DRIVER_OVERRIDE=YOUR_DRI_DRIVER at the beginning of the script that runs matlab (_YOUR_MATLAB_FOLDER/bin/matlab), although I suppose it can also be set as an environment variable.
I hope this has been useful to you.
Related
I have just started to work in a project where the product uses a imx8m mini module together with Yocto Linux (Zeus).
Currently we have a problem related to the shutdown behavior of the product, and we need to modify what happens during a shutdown.
As today when we shutdown or a thermal emergency happens, the PMIC_ON_REQ(That controls the external power regulator) goes low, but we need to change this behavior that it keeps the current value on PMIC_ON_REQ, as we have other diagnostic devices that needs to talk to the PMIC after that the imx8mm has turned off. In other words: I want to keep the value of the gpio as long as possible, until the control is out of reach.
But my current problem is that I don't know where to start, or what kernel module I shall look into.
Does any one have any clue where I shall start to look to be able to find the code for patching?
I have tried commands in devtool like "devtool modify power/thermal/soc" but without finding the needed code..
Please observe that this is my first Yocto project ever, so if I write something strange, bare with me
I've written a shared library in C/C++ for MATLAB to create an API for a Monochrome camera.
The code works, but I have some odd issues with memory management (basically the MATLAB functions for freeing/dynamically allocating aren't too reliable). Additionally I have some other really low level things I'd like to debug like looking at values of register holding raw camera buffer.
I can write standalone C Code and launch it with GDB, however a child process will crash the software as only 1 thread is allowed to open a connection to camera at a time. If I don't set break points within the code interacting with device all is fine. But I want to stop the program say after acquiring image buffer, but before copying the data into MATLAB output, the child process spawned by the debugger causes everything to lock up.
Anyone know how I might address this?
Edit: "Unreliable" is not a good wording. Basically, I retrieve an image buffer from camera (which is dynamically allocated because image bitdepth is variable). This array is created/destroyed with mxMalloc and mxDestroyArray which works okay if I have MATLAB_MEM_MGR enabled. This is part of what I would like to debug inside MEX. The other is comparing the raw byte values of the image buffer before coming back to matlab.
Additional Clarification:
The error I get in GDB is actually a GenICam error for RESOURCE_IN_USE. My intuition is because the parent process hasn't released the camera resources, the child thread started actually causes issues if that makes sense.
On Windows, it seems somewhat dangerous to switch from VC++ to MinGW-w64 for a MEX, as you can easily wind up with the classic Windows bug of having multiple copies of libc. See the warning here, "Do not link to library files compiled with non-MinGW compilers". A MEX built with 'gcc' will pull in malloc() and free() from msvcrt.dll, whereas any DLLs you link against that were built with 'cl' will pull in ucrtbase.dll instead. That could easily lead to crashes, if for instance gcc-compiled code calls free() on a block allocated using malloc() in cl-compiled code.
The gdb.exe installed by MATLAB does seem to behave somewhat strangely, especially when I press Control-C. It doesn't like Cygwin terminals either. It does spawn a weird 'gdborig' helper process. Finally, I kept seeing a Microsoft A/V tool, mpcmdrun, firing off as I was playing with it. You might try the newer gdb installed by MSYS2 (although I may have seen A/V there as well).
Indeed, some random child process probably inherited the device connection handle, causing the lock-up. But that child process might be something else... not be the extra one created by that silly old version of gdb (7.11.1).
Setup: Matlab Student 2014, Psychtoolbox 3.0.12, GStreamer 1.4.3, ATI Radeon 69xx, all on Windows 7, all 64bit.
Screen works with different arguments, only at Screen('OpenMovie' the whole Program (Matlab) crashes - sometimes with Error (unable to synchronize framerate), sometimes no error at all.
I know it is quite specific and I think it is somehow in my configuration (the code will work on a different system (lab)).
What I've tried so far:
Psychtoolbox 3.0.11, GStreamer SDK, GStreamer 1.4.1
renewed ATI drivers (complete catalyst control center,..)
removed multi-monitor setting (makes it harder to debug then..)
Matlab itself works, GStreamer too (tried playing movie with playbin)
anything SyncTrouble states: wait for vertical synch, triple buffering off
overriding sync-tests or skipping at all (also crash)
looking for missing dlls (for Screen.mexw64)
VBLSyncTest and PerceptualVBLSyncTest look fine and have results (for me)
It has to be either something very simple, or very specific - I'm somehow out of ideas. My guess would be that the Radeon vertical sync on setting does not work - for what reason ever.
ANY guesses, tips are apreciated. (even other ways to test Screen or vertical sync in Matlab/Psychtoolbox)
after hours of search, I think I've found a solution - oh Windows! (and oh, one simple line of code)
Screen('Preference', 'ConserveVRAM', 4096);
4096 == kPsychUseBeampositionQueryWorkaround
Tell PTB to always use the workaround for broken beamposition queries in
VBL on MS-Windows, even if the automatic startup test does not detect any
problems. This for rare cases where the test fails to detect broken
setups. [Psychtoolbox Docs]
I will do a recheck after some Videocache action and restarts.
edit:
well, that did only work once, and randomly a second time - it seems like the ATI Radeon driver behave not quite deterministically - I also checked on a Linux (Ubuntu 14.04.1). Specifically, the VSync rate seems to behave somehow strangely.
It generally works on that specified Linux with the open source radeon drivers (instead of the fglrx ones) though. -> The Problem on that Linux system: it can only be configured as one Screen (two monitor setup would be nice for debug on one Screen). (Yes, I've tried: Unity, Gnome, Xmonad, Gnome+Xmonad - but I guess that is another story)
Alright, I've written enough, my solution: use a Linux distro (quite unsatisfying though, as I could not accomplish for everything to work).
I have a Simulink model that uses an s_function, which is a mexw32 file. The s_function block uses a .lib module as well. Now, when I'm trying to run the model Matlab crash before the simulation end and without any errors in the command window. What are my options for debugging if Matlab crash?
This is typical behaviour of a badly written S-function that is causing a seg-fault. Debug it using the steps outlined at: http://www.mathworks.com/support/solutions/en/data/1-3KK6RK/
I dont know about Simulink or S-functions (never used them), but usually when a MEX-file segfaults, MATLAB will recover from it most of the times, showing a stack trace and placing you in the "you need to restart MATLAB" command prompt mode. You'll find a crash dump and error log files in the system %TMP% folder.
As other have said, if you have access to the source code of the MEX-function, recompile it with debugging symbols, attach a debugger to MATLAB, place breakpoints in the debugger, and initiate the MEX-function by calling it from MATLAB. Once inside the C code, debug it code step by step until you find the problem.
Here is the relevant doc page describing this process in more details.
You mentioned that your MEX-executable is linked against an external library. So you might also want to check that for the source of the problem.
(Running MATLAB 8.1.0.604 (R2013a), Mac OS 10.8.3)
When I use the doc command, for example, doc fwrite;, or when I click the "more help" item in the popup help bubble for a command, the documentation window opens, but MATLAB subsequently hangs (the spinning beachball appears). This lasts indefinitely, and I inevitably have to force quit MATLAB. This also happens when using the Publish option from the editor.
Anyone have any ideas for diagnosing this? I tried taking a process sample but I didn't see any info I could interpret, I think since it's in Java the relevant information is obfuscated behind the JVM.
See this post on MatlabCentral: http://www.mathworks.com/matlabcentral/answers/71718 ... and more specifically this bug report which includes a "workaround." They don't suggest what could be the cause, but you might make sure that OS X is updated and that you have the latest version of Java. If you do other work with Java or with WebKit these might cause issues.
I hope you have already solved the problem. Otherwise a solution has been found, the bug resides in the Access for Assistive devices (only for version 2012b and later). If you can turn them all off from System Preferences, do that. If you can't, type this in the command window:
com.mathworks.mlwidgets.html.HtmlComponentFactory.setBrowserProperty('JxBrowser.BrowserType','Mozilla15');
From http://www.mathworks.com/support/bugreports/870843
I had the same problem with Matlab R2014a on OS 10.10.4. For me the solution involved disabling Cinch (a window management tool I had installed). This can be done by clicking on the Cinch icon in the menu bar then Disable Cinch, or from System Preferences > Security and Privacy > Accessibility (as MarcoB detailed in his answer).
More suitable as comments (but I don't have enough rep yet):
I just updated to Java 1.8.0_73 and to Safari 9.1 and the patch horchler posted no longer works.
MarcoB's command still works for fixing the crashes. But with this, no longer retina resolution in the Doc browser (so it looks ugly).