At the risk of overstating the obvious, the only reason for the error in question to be generated by eglCreateWindowSurface is if the native window handle passed in is not valid (not an actual native window handle, not a window "belonging" to the client, etc.). Trying to create a new surface for a native window handle that already has one is a different error (by the spec). eglMakeCurrent can also generate that error for basically the same reason (let's say you destroyed the native window after creating the EGLSurface, when you call make current it will tell you that it's not valid). I'll get very depressed if someone is actually shipping an implementation that only supports one context per process (obviously only one can be bound to a thread at any given time, but you should be able to have as many as you have memory to track).
At the risk of overstating the obvious, the only reason for the error in question to be generated by eglCreateWindow Surface is if the native window handle passed in is not valid (not an actual native window handle, not a window "belonging" to the client, etc.). Trying to create a new surface for a native window handle that already has one is a different error (by the spec). eglMakeCurrent can also generate that error for basically the same reason (let's say you destroyed the native window after creating the EGLSurface, when you call make current it will tell you that it's not valid). I'll get very depressed if someone is actually shipping an implementation that only supports one context per process (obviously only one can be bound to a thread at any given time, but you should be able to have as many as you have memory to track).