Bug 368703 - Failed shader compilation causes immediate crash
Summary: Failed shader compilation causes immediate crash
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: OpenGL Canvas (show other bugs)
Version: git master (please specify the git hash!)
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Halla Rempt
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-09-12 15:22 UTC by Nimthora
Modified: 2016-12-08 09:55 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
error-report (204.50 KB, application/msword)
2016-09-17 05:13 UTC, n7down
Details
error message (423.56 KB, image/png)
2016-09-17 05:21 UTC, n7down
Details
shader compiler errors (9.62 KB, text/plain)
2016-09-20 16:51 UTC, Patrice Kouame
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nimthora 2016-09-12 15:22:04 UTC
Failing to compile a shader calls a function to show a QMessageBox::critical(). This works, however after setting the useOpenGL setting to false in the configuration the canvas isn't exchanged for a non-OpenGL one. This results in a failed assertion by Qt:

ASSERT: "ctx && fbo" in file kernel/qopenglwidget.cpp, line 822


Reproducible: Always

Steps to Reproduce:
1. Change a letter in e.g. simple_texture.frag so that it won't compile properly anymore
2. Start Krita with OpenGL on and create a canvas
3. Krita flashes a message box and then crashes

Actual Results:  
Krita crashes

Expected Results:  
Krita should revert to software rendering and show this nice message box to the user
Comment 1 n7down 2016-09-17 05:13:18 UTC
Created attachment 101130 [details]
error-report

this is the error-report produced after krita crashes
Comment 2 n7down 2016-09-17 05:21:42 UTC
Created attachment 101133 [details]
error message
Comment 3 n7down 2016-09-17 05:23:47 UTC
I am experience a similar (if not the same) issue with Krita 3.0.2 on OSX 10.11.6. Krita was working fine for a couple of hours then then it started to give an throw an message which says: "Krita could not initialize the OpenGL canvas: Failed to add vertex shader source from file: matrix_transform.vert Krita will disable OpenGL and close now". This occurs when creating a custom document then krita immediately crashes. This only happens when OpenGL is enabled under preferences > display, otherwise Krita seems to be working fine.

Attached image of the error message and the error report created by OSX when krita crashes.

Reproducible: Always

Steps to Reproduce:
1. Make sure OpenGL is enabled under preferences > display
2. Open or create a new document
3. Krita will flash an error message then immediately crash

The following is the debug statements that show up in terminal while running krita and then crashing:

QCoreApplication::arguments: Please instantiate the QApplication object first
krita.lib.pigment: Compiled for arch: 7
krita.lib.pigment: Features supported:
krita.lib.pigment: 	 "SSE2" 	---	 yes
krita.lib.pigment: 	 "SSSE3" 	---	 yes
krita.lib.pigment: 	 "SSE4.1" 	---	 yes
krita.lib.pigment: 	 "AVX " 	---	 yes
krita.lib.pigment: 	 "AVX2 " 	---	 yes
Set style "fusion"
OpenGL Info
  Vendor:  Intel Inc.
  Renderer:  Intel(R) Iris(TM) Graphics 6100
  Version:  4.1 INTEL-10.14.73
  Shading language:  4.10
  Requested format:  QSurfaceFormat(version 3.2, options QFlags(), depthBufferSize 24, redBufferSize -1, greenBufferSize -1, blueBufferSize -1, alphaBufferSize -1, stencilBufferSize 8, samples -1, swapBehavior 2, swapInterval 0, profile  1)
  Current format:    QSurfaceFormat(version 4.1, options QFlags(), depthBufferSize 24, redBufferSize 8, greenBufferSize 8, blueBufferSize 8, alphaBufferSize -1, stencilBufferSize 8, samples -1, swapBehavior 2, swapInterval 1, profile  1)
     Version: 4 . 1
     Supports deprecated functions false
krita has opengl true
Setting XDG_DATA_DIRS "/Users/n7down/Source/kde/dev/i/bin/krita.app/../../share"
Available translations QSet("en_US")
Available domain translations QSet("en_US")
Override language: ""
libpng warning: iCCP: too many profiles
libpng warning: iCCP: too many profiles
libpng warning: iCCP: too many profiles
libpng warning: iCCP: too many profiles
"KConfigIni: In file /Users/n7down/Source/kde/dev/i/share/krita/osx.stylesheet, line 1: " Invalid entry (missing '=')
"KConfigIni: In file /Users/n7down/Source/kde/dev/i/share/krita/osx.stylesheet, line 2: " Invalid entry (missing '=')
"KConfigIni: In file /Users/n7down/Source/kde/dev/i/share/krita/osx.stylesheet, line 3: " Invalid entry (missing '=')
"KConfigIni: In file /Users/n7down/Source/kde/dev/i/share/krita/osx.stylesheet, line 4: " Invalid entry (missing '=')
"KConfigIni: In file /Users/n7down/Source/kde/dev/i/share/krita/osx.stylesheet, line 6: " Invalid entry (missing '=')
"KConfigIni: In file /Users/n7down/Source/kde/dev/i/share/krita/osx.stylesheet, line 7: " Invalid entry (missing '=')
"KConfigIni: In file /Users/n7down/Source/kde/dev/i/share/krita/osx.stylesheet, line 8: " Invalid entry (missing '=')
"KConfigIni: In file /Users/n7down/Source/kde/dev/i/share/krita/osx.stylesheet, line 9: " Invalid entry (missing '=')
"KConfigIni: In file /Users/n7down/Source/kde/dev/i/share/krita/osx.stylesheet, line 11: " Invalid entry (missing '=')
"KConfigIni: In file /Users/n7down/Source/kde/dev/i/share/krita/osx.stylesheet, line 12: " Invalid entry (missing '=')
"KConfigIni: In file /Users/n7down/Source/kde/dev/i/share/krita/osx.stylesheet, line 13: " Invalid entry (missing '=')
"KConfigIni: In file /Users/n7down/Source/kde/dev/i/share/krita/osx.stylesheet, line 14: " Invalid entry (missing '=')
"KConfigIni: In file /Users/n7down/Source/kde/dev/i/share/krita/osx.stylesheet, line 15: " Invalid entry (missing '=')
"KConfigIni: In file /Users/n7down/Source/kde/dev/i/share/krita/osx.stylesheet, line 16: " Invalid entry (missing '=')
"KConfigIni: In file /Users/n7down/Source/kde/dev/i/share/krita/osx.stylesheet, line 17: " Invalid entry (missing '=')
libpng warning: iCCP: too many profiles
krita.lib.flake: "InteractionTool" : action "object_order_lower" conflicts with canvas action "rotate_canvas_left" shortcut: "Ctrl+["
krita.lib.flake: "InteractionTool" : action "object_order_raise" conflicts with canvas action "rotate_canvas_right" shortcut: "Ctrl+]"
krita.lib.flake: "InteractionTool" : action "object_order_lower" conflicts with canvas action "rotate_canvas_left" shortcut: "Ctrl+["
krita.lib.flake: "InteractionTool" : action "object_order_raise" conflicts with canvas action "rotate_canvas_right" shortcut: "Ctrl+]"
QOpenGLShader::compile(Vertex): ERROR: 0:1: '' :  version '130' is not supported
ERROR: 0:2: '' :  #version required and missing.

*** Problematic Vertex shader source code ***
#version 130
#define lowp
#define mediump
#define highp
#line 2
/*
 * Vertex shader for handling scaling
 */

uniform mat4 modelViewProjection;
uniform mat4 textureMatrix;

in vec4 a_vertexPosition;
in vec4 a_textureCoordinate;

out vec4 v_textureCoordinate;

void main()
{
    gl_Position = modelViewProjection * a_vertexPosition;
    v_textureCoordinate = textureMatrix * a_textureCoordinate;
}

***
Shader Compilation Failure:  "Failed to add vertex shader source from file: matrix_transform.vert"
[1]    30312 segmentation fault  ../dev/i/bin/krita.app/Contents/MacOS/krita
Comment 4 Halla Rempt 2016-09-17 07:12:10 UTC
That is interesting -- it's not the same thing as the original bug report was about, though. But I'm wondering how it can be that with opengl 4.1 enabled, as per your log, a #version 130 is a problem. I'll have to ask nimmy when he wakes up...
Comment 5 Nimthora 2016-09-17 12:48:29 UTC
I had to change 150 core to 130 for this Qt5.6 dilemma. I guess we need another #ifdef to put in 150 core on OS X instead. Will fix that, different problem than the bugreport though.
Comment 6 n7down 2016-09-19 15:48:28 UTC
Sorry about the mistake, should I create another bug? Or will those changes be submitted to this bug report?
Comment 7 Nimthora 2016-09-19 18:23:08 UTC
Hi n7down, your problem should already be fixed in the latest master.
Comment 8 n7down 2016-09-20 03:11:19 UTC
terrific thanks
Comment 9 Patrice Kouame 2016-09-20 15:34:27 UTC
I can confirm it's been fixed on macOS in the latest master.

Patrice

Test Environment
Krita 3.0.2 beta b9c7f564101b12e4f1a102b79ad588226795cbfe
mac pro 3,1
NVIDIA GeForce GTX 680 2G
macOS Sierra GM
Xcode 8 Release
Comment 10 Patrice Kouame 2016-09-20 16:50:05 UTC
NOTE: Whereas the crash is fixed.  The shader loader is still not happy.  Check out my attached log.
Missing version strings in shaders this time around...

For me, running bleeding edge krita master on unpatched Qt5.7 without Nim's changes required hard coding a format.setVersion(2, 1) .  Seems like even with 4.1 enabled and format.setVersion(3, 2) macOS really just gives you a core 2.1 profile...Avoided the brutal seg.

Patrice

Test Environment
Krita 3.0.2 beta b9c7f564101b12e4f1a102b79ad588226795cbfe
mac pro 3,1
NVIDIA GeForce GTX 680 2G
macOS Sierra GM
Xcode 8 Release
Comment 11 Patrice Kouame 2016-09-20 16:51:03 UTC
Created attachment 101203 [details]
shader compiler errors
Comment 12 Nimthora 2016-09-20 18:12:05 UTC
Hi Pkouame,

The problem you face with that crash is that bleeding edge master now requires a patched Qt5.7 until Qt adds my changes. Using an unpatched Qt5.7 breaks everything because we ask for a 3.2 Core Profile (which you **do** get btw, you get a 4.1 core profile) and this profile deprecates all of Qt's legacy shaders. This is why it gives you shader compilation errors showing Qt's inner shaders.

Setting the format back to 2.1 will cause you to revert to the state of Krita before my changes, which means no instant preview and high quality filtering.

If you want to try the bleeding edge Krita you should use the Qt we pack with Krita and its applied patches and remove your 2.1 format setting.
Comment 13 Patrice Kouame 2016-09-20 18:34:47 UTC
Hey Nim -

Yes, I fully understand that and usually turn off openGL when playing around with master.  Setting back to 2.1 is just a quick workaround to look at other things. Not meant as a recommendation to anyone.  Just wanted to relate and (explain) my experience to n7down  who may be in the same boat on macOS.

On another note,  I've been on krita+Qt5.7 on mac for a while now. In fact, the release notes in 3rdparty suggested (once?) that it wasn't a requirement (boud confirmed it informally), so I felt safe sticking with a "virgin" Qt5.7 straight out of the box.  Are you saying, I should revert to 5.6 or ext_qt until 3.1 and your changes hit the street?
Comment 14 Halla Rempt 2016-09-20 18:36:40 UTC
On OSX, with git master, you must have Qt 5.7 patched with the patch in the ext_qt folder.
Comment 15 Patrice Kouame 2016-09-20 18:38:27 UTC
understood.
Comment 16 Halla Rempt 2016-12-08 09:55:38 UTC
I'm pretty sure that with 3.1 rc1 this isn't an issue anymore -- if Krita is built with a correctly patched Qt, so I am going to close this bug.