First we find the integrating factor.
Note that
\begin{equation}
M_y=2x\cdot\cos(y) - 2xy\cdot\sin(y) - 2y\cdot\cos(x)
\end{equation}
\begin{equation}
N_x=4x\cdot\cos(y) - 2xy\cdot\sin(y) - 3y\cdot\cos(x)
\end{equation}
\begin{equation}
N_x - M_y=2x\cdot\cos(y) - y\cdot\cos(x)
\end{equation}
\begin{equation}
(N_x - M_y)/M=1/y
\end{equation}
Therefore, the integrating factor is only dependent on y.
\begin{equation}
\ln u= \ln y
\end{equation}
\begin{equation}
u(y)= y
\end{equation}
Multiply u(y) on both sides of the equation. Then we have
\begin{equation}
\phi_x=2xy^2\cos(y) - y^3\cos(x)
\end{equation}
\begin{equation}
\phi=x^2y^2\cos(y) -y^3\sin(x) +h(y)
\end{equation}
\begin{equation}
\phi_y=2x^2y\cos(y) -x^2y^2\sin(y) - 3y^2\sin(x) +h^\prime(y)
\end{equation}
By comparison, we get
\begin{equation}
h^\prime(y)=-5y^4
\end{equation}
\begin{equation}
h^\prime(y)=-y^5
\end{equation}
Then we have
\begin{equation}
\phi=x^2y^2\cos(y)-y^3\sin(x) -y^5
\end{equation}
The general solution is
\begin{equation}
\phi=x^2y^2\cos(y)-y^3\sin(x) -y^5=c
\end{equation}