diff --git a/pixelgl/shader.go b/pixelgl/shader.go
index 42bf413895900dbdc6e5200d7af4704f8ba94394..ce638a38e1b7dbdc015e80341ae90d64ae46c601 100644
--- a/pixelgl/shader.go
+++ b/pixelgl/shader.go
@@ -181,7 +181,7 @@ func (s *Shader) SetUniformAttr(attr Attr, value interface{}) (ok bool) {
 	}
 
 	DoNoBlock(func() {
-		defer s.program.bind().restore()
+		s.program.bind()
 
 		switch attr.Type {
 		case Int:
@@ -229,6 +229,8 @@ func (s *Shader) SetUniformAttr(attr Attr, value interface{}) (ok bool) {
 		default:
 			panic("set uniform attr: invalid attribute type")
 		}
+
+		s.program.restore()
 	})
 
 	return true