WARNING: Output of vertex shader 'v_gradient' not read by fragment shader
Asked Answered
P

2

47

When i run my app in ios 10 using xcode 8 i am getting following message in debug console, and by UI getting freezed can any one know why this is happening

 ERROR
 /BuildRoot/Library/Caches/com.apple.xbs/Sources/VectorKit/VectorKit-1228.30.7.17.9/GeoGL/GeoGL/GLCoreContext.cpp
 1763: InfoLog SolidRibbonShader: ERROR
 /BuildRoot/Library/Caches/com.apple.xbs/Sources/VectorKit/VectorKit-1228.30.7.17.9/GeoGL/GeoGL/GLCoreContext.cpp
 1764: WARNING: Output of vertex shader 'v_gradient' not read by
 fragment shader
Peso answered 21/9, 2016 at 5:32 Comment(8)
I have encounter this issue too.Stromboli
@noellee are you using mapview in your appPeso
@vais i've encountered same errors, i use MKMapSnapshotter and MapView. I've get errors on both.Cotidal
@AndreyM. yes i am also using MKMapviewPeso
I am also using MKMapView and getting this error.Billings
my application freezed only in debugging mode otherwise everything works fine, but still gets this warningPeso
I can confirm this happens only in debug builds. But definitely a bug that should be reported to Apple.Conclude
I have a map view in the page. However this bug only occurs when I have an inputAccessoryView on the VC.Centuple
T
52

Answer

One of the situations where you might get this warning in Xcode is when using an app that uses shaders such as the Maps app with an MKMapView. You'll find that the map view works as expected without that warning on a real device with real hardware/native OS.

In the sim the SolidRibbonShader fragment shader is not able to read the output of the v_gradient vertex shader probably because it's in beta or there might be an incompatibility between Xcode version and SIM version. However the shaders are recognized on a real device.

Explanation

Those shaders belong to the OpenGL Rendering Pipeline. The Rendering Pipeline is the sequence of steps that OpenGL takes when rendering objects.

The rendering pipeline is responsible for things like applying texture, converting the vertices to the right coordinate system and displaying the character on the screen etc.

There are six stages in this pipeline.

  1. Per-Vertex Operation
  2. Primitive Assembly
  3. Primitive Processing
  4. Rasterization
  5. Fragment Processing
  6. Per-Fragment Operation

Finally, an image appears on the screen of your device. These six stages are called the OpenGL Rendering Pipeline and all data used for rendering must go through it.

What is a shader?

A shader is a small program developed by you that lives in the GPU. A shader is written in a special graphics language called OpenGL Shading Language(GLSL).

A shader takes the place of two important stages in the OpenGL Rendering Pipeline: Per-Vertex Processing and Per-Fragment Processing stage. There is one shader for each of these two stages.

The ultimate goal of the Vertex Shader is to provide the final transformation of the mesh vertices to the rendering pipeline. The goal of the Fragment shader is to provide Coloring and Texture data to each pixel heading to the framebuffer.

Vertex shaders transform the vertices of a triangle from a local model coordinate system to the screen position. Fragment shaders compute the color of a pixel within a triangle rasterized on screen.

Separate Shader Objects Speed Compilation and Linking

Many OpenGL ES apps use several vertex and fragment shaders, and it is often useful to reuse the same fragment shader with different vertex shaders or vice versa. Because the core OpenGL ES specification requires a vertex and fragment shader to be linked together in a single shader program, mixing and matching shaders results in a large number of programs, increasing the total shader compile and link time when you initialize your app.

Tremolite answered 26/10, 2016 at 7:14 Comment(5)
yes but what we can do to it ? Waiting to be debug by Apple ?Mealie
The answer is the correct reason for the warning message. Stack answers are sometimes code solutions or simply answers to Xcode or iOS questions. This answer is the correct explanation and the answer also says that the shaders will load fine on an actual device so that is also a solution.Gentility
Fits my experience as well: an issue on the simulator, not the device.Outrider
Nice answer, but I have this problem on my real device (iPhone 5C, iOS 10.2 but also appeared on earlier versions, XCode 8.2). I build my app and run it on iPhone - in console appears error from the question (with different VectorKit version).Hebdomad
I have the same problem on my device (iPhone 5, iOS 10.3.2, and Xcode 8.3.3), but in my other device (iPhone 6, iOS 10.3.2 and iPhone 4s, 9.3.5) I don’t have the problem. I guess that’s a problem on iPhone 5.Gavingavini
C
3

Update: the issue seems to be gone now on Xcode9/iOS11.


Firstly, the freezing problem happens only when run from Xcode 8 and only on iOS 10 (currently 10.0.2), whether in debug or release mode. MKMapView though seems fine when the app is distributed via App Store or 3rd party ad hoc distribution systems. The warnings you are seeing may or may not be related to the problem, I don't know.

What I've found is that the offending code is in MKMapView's destructor, and it doesn't matter what you do with the map view object or how you configure it, i.e. merely calling

[MKMapView new];

anywhere in your code will freeze the app. The main thread hangs on a semaphore and it's not clear why.

One of the things I've tried was to destroy the map view object in a separate thread but that didn't help. Eventually I decided to retain my map objects at least in DEBUG builds.

NOTE: this is a really sh*tty workaround but at least it will help you to debug your app without freezing. Retaining these objects means your memory usage will grow by about 45-50MB every time you create a view controller with a map.

So, let's say if you have a property mapView, then you can do this in your view controller's dealloc:

- (void)dealloc
{
#if DEBUG
    // Xcode8/iOS10 MKMapView bug workaround
    static NSMutableArray* unusedObjects;
    if (!unusedObjects)
        unusedObjects = [NSMutableArray new];
    [unusedObjects addObject:_mapView];
#endif
}
Conclude answered 29/9, 2016 at 12:6 Comment(5)
I just noticed this as well. Did you by chance open a radar?Lowly
might be related to my question too actually... #41870203Ezarra
Somebody reported it? I had the same issue.Ezarra
This is still happening on iOS 10.3.3, anyone reported it yet?Joinder
For me, it hangs only when the app is run with the debugger (Xcode) attached, so instead of #if DEBUG, I use if(AmIBeingDebugged()).Bennet

© 2022 - 2024 — McMap. All rights reserved.