The integration of
$$\int^\pi_0 \sin(\theta) \delta(\cos\theta - 1)\, d \theta$$
can be derived by replacing $d\theta$ with $d\cos\theta$
$$\begin{align*} \int^\pi_0 \sin(\theta) \delta(\cos\theta - 1)\, d \theta &= -\int^{-1}_1 \delta(x - 1)\, dx \quad (\text{let } x = \cos\theta, dx = -\sin(\theta)\,d\theta) \\ &= \int^1_{-1} \delta(x - 1)\, dx \\ &= 1 \end{align*}$$
However, if I don't replace the base and apply the definition of Dirac delta ($\int f(x)\delta(x -a)\,dx = f(a)$)directly, the result become $0$.
$$\begin{align*} \int^\pi_0 \sin(\theta) \delta(\cos\theta - 1)\, d \theta &= \sin(0) \\ &= 0 \end{align*}$$
What is wrong with the second approach?
I have seen the other solution that replace $\delta(\cos\theta - 1)$ at Dirac delta integral of cosx
$$\begin{align*} \int^\pi_0 \sin(\theta) \delta(\cos\theta - 1)\, d \theta &= \int^\pi_0 \sin(\theta) \frac{\delta(\theta - \frac{\pi}{2})}{|-\sin\frac{\pi}{2}|}\, d \theta \\ &= \int^\pi_0 \sin(\theta) \delta(\theta - \frac{\pi}{2})\, d \theta \\ &= \sin(\frac{\pi}{2}) \\ &= 1 \end{align*}$$
Is the replacement of the Dirac delta function necessary? Why it's required and how is the replacement derived?
What if the second integral method produces the correct result ?
Notice that the third method (with the link) uses the result of $\delta(\cos \theta)$ rather than finding the root of $\delta(\cos \theta - 1)$. The zero should be found from the equation $\cos \theta_{0} = 1$ which gives $0 + 2 \, n \, \pi$ and not the $\frac{\pi}{2}$ given in the example (which is the root of the equation $\cos \theta_{1} = 0)$.
The given integral $$ \int \sin(a \theta) \, \delta(\cos(a \theta) - b) \, d\theta$$ can be integrated directly by making use of the Heaviside step function as seen by $$ \int \sin(a \theta) \, \delta(\cos(a \theta) - b) \, d\theta = - \frac{1}{a} \, H(\cos(a \theta) - b) + c_{0}.$$ Evaluating this integral for the limits desired gives $$ \int_{0}^{\pi} \sin(a \theta) \, \delta(\cos(a \theta) - b) \, d\theta = \frac{H(1 - b) - H(\cos(a \pi) - b)}{a}. $$ If $a = 1$ then $$ \int_{0}^{\pi} \sin(\theta) \, \delta(\cos(\theta) - b) \, d\theta = H(1 - b) - H(-1 - b) $$ and if $b=1$ the result reduces to $$ \int_{0}^{\pi} \sin(\theta) \, \delta(\cos(\theta) - 1) \, d\theta = 0. $$
A related integral is given in this question and solution Integrating Dirac delta functions with trigonometric arguments