Is h6 or g6 better to defend the h7 square against a combined attack by a queen and bishop? I am setting the question from black's perspective, but it holds the same for white too.

Many times in my personal games a position arises where a Bishop along the b1-h7 diagonal and a Queen on the h-file put pressure on the h7 square, sometimes even threatening a straight checkmate.

Not considering cases of using other pieces to defend h7, both pawn moves g7-g6 and h7-h6 prevent this threat.

My question is out of these two pawn moves, under my conditions, what is the decisive factor in choosing one over other?

For representative purposes I am using a position from round 9 match between 
Jan-Krzysztof Duda and Alexei Shirov that happened last day (27th December 2019) at world rapid chess championship, but my question is on general ideas of this threat by queen and bishop.

[fen "r1bqr1k1/pp3ppp/2pb1n2/3n4/3P3Q/P1NB1N2/1P3PPP/R1B2RK1 w - - 0 1"]
First, there is no hard-and-fast rule, but if I were to generalize, probably Pg6 in more cases as it blunts the incredibly dangerous Bd3. Playing h6 in some positions invites Bxh6 in many cases.

In the game you reference, Shirov played h6, but he also knows that Bh6 gh; Qh6 ideas will immediately be met by Bf8-g7, which is a common saving idea. In other words, he was prepared because his previous developing moves were good.

Black's best plan was obvious and it was to trade down, which Shirov did. The position was dangerous, and trading is the most common plan in such positions.

In the given position, black also has a couple of addition pluses that make h6 preferable, and they are that he can trade material on c3, potentially reducing white's attacking chances, and the biggest one is the Re8 controls the file, and allowed for the Bf8-g7 defense previously mentioned. Often these attacks for white require a rook-lift, with Re1-e3-g3(or h3), but it is clear that is impossible here.

Shirov only lost as the result of a blunder later in a winning position.

 [FEN ""]
 [Event "World Rapid 2019"]
 [Site "Moscow RUS"]
 [Date "2019.12.27"]
 [Round "9.11"]
 [White "Duda, Jan-Krzysztof"]
 [Black "Shirov, Alexei"]
 [Result "1-0"]
 [WhiteElo "2758"]
 [BlackElo "2684"]
 [PlyCount "111"]

 1. c4 c6 2. Nf3 d5 3. e3 Nf6 4. Nc3 Nbd7 5. Qc2 e5 6. cxd5 Nxd5 7. Bc4 Nb4 8. Qe4 Bd6 9. O-O O-O 10. d4 Re8 11. a3 Nf6 12. Qh4 exd4 13. exd4 Nbd5 14. Bd3 h6 15. Bd2 Nxc3 16. bxc3 Bg4 17. a4 Bxf3 18. gxf3 Nd5 19. Qg4 Qf6 20. Rab1 Bf4 21. c4 Bxd2 22. cxd5 Rad8 23. dxc6 Rxd4 24. Be4 bxc6 25. Rb7 Rxa4 26. Bh7+ Kxh7 27. Qxa4 Qxf3 28. Qc2+ f5 29. Qxd2 Re6 30. Rc1 Rg6+ 31. Kf1 Qh1+ 32. Ke2 Re6+ 33. Kd3 Rd6+ $4 (33... Qf3+ {Wins the queen.}) 34. Kc3 Qf3+ 35. Qe3 Qd5 36. Rg1 Qa5+ 37. Kb3 Qd5+ 38. Kb2 Rd7 39. Rxd7 Qxd7 40. Ra1 c5 41. Qxc5 Qd2+ 42. Kb3 Qd3+ 43. Kb4 Qd2+ 44. Ka4 Qf4+ 45. Ka5 Qd2+ 46. Ka6 Qd3+ 47. Kxa7 Qd7+ 48. Ka6 Qd3+ 49. Ka5 Qd2+ 50. Ka4 Qf4+ 51. Ka3 Qf3+ 52. Qe3 Qa8+ 53. Kb2 Qb8+ 54. Kc2 Qxh2 55. Ra5 Qc7+ 56. Qc5 1-0