Contradiction between Galilean transformation and conservation of mechanical energy 
Consider the system described by the above diagram. The table is frictionless and the string and the pulley are massless. Suppose that at heights $h$ and $\widetilde{h}$ of $m_2$ the corresponding relevant speed components of the masses are $u_{1x} = u_{2y}$ and $\widetilde{u}_{1x} = \widetilde{u}_{2y}$ respectively. Then the conservation of energy tells us that
$$\frac{1}{2} m_1 u_{1x}^2 + \frac{1}{2}m_2 u_{2y}^2 + m_2gh = \frac{1}{2} m_1 \widetilde{u}_{1x}^2 + \frac{1}{2}m_2 \widetilde{u}_{2y}^2 + m_2 g \widetilde{h}.$$
If there is another frame moving at a constant velocity $v$ in the $X$ direction with respect to the frame used earlier, then we apply the Galilean transformation as
$$u'_{1x} = u_{1x} - v,$$
$$u'_{2x} = -v,$$
$$u'_{2y} = u_{2y},$$
$$\widetilde{u}'_{1x} = \widetilde{u}_{1x} - v,$$
$$\widetilde{u}'_{2x} = -v,$$
$$\widetilde{u}'_{2y} = \widetilde{u}_{2y},$$
and since energy is also conserved in that frame,
$$\frac{1}{2} m_1 {u'_{1x}}^2 + \frac{1}{2}m_2 {u'_{2y}}^2 + \frac{1}{2}m_2 v^2 + m_2 gh = \frac{1}{2} m_1 {\widetilde{u}'_{1x}}^2 + \frac{1}{2}m_2 {\widetilde{u}'_{2y}}^2 + \frac{1}{2}m_2 v^2 + m_2 g \widetilde{h}.$$
Applying to this equation the relation with the primed and unprimed velocities according to the Galilean transformation, we obtain after some simplification
$$\frac{1}{2} m_1 u_{1x}^2 + \frac{1}{2}m_2 u_{2y}^2 + m_2gh - m_1 u_{1x} v = \frac{1}{2} m_1 \widetilde{u}_{1x}^2 + \frac{1}{2}m_2 \widetilde{u}_{2y}^2 + m_2 g \widetilde{h} - m_1 \widetilde{u}_{1x} v.$$
Using the conservation of energy in the unprimed frame we finally obtain
$$u_{1x} = \widetilde{u}_{1x}.$$
which is contradictory because $u_{1x}$ changes as height changes. Did I implicitly assume somewhere that $h = \widetilde{h}$? From my understanding of Galilean invariance there shouldn't be any such contradiction.
 A: Thanks to the OP for posting this great question which evokes the requirement of the subtle understanding of the work-energy theorem and energy conservation equation used in mechanics.

*

*Using the notation in the post,

*agreeing with the speeds calculated with respect to the primed frame in the orginal post except ${u}^{'}_{2y} = u_{2y}$ and $\tilde{u}^{'}_{2y} = \tilde{u}_{2y}$, so that in general $u^{'}_{1x} \neq u^{'}_{2y}$ although $u^{}_{1x} = u^{}_{2y}$,

*noting that $u^{}_{1x}(t) = u^{}_{2y}(t)$ due to the geometric constraint of the mechanism, $u^{'}_{1x}(t) = u^{}_{1x}(t) - v$ and $u^{'}_{2y}(t) = u^{}_{2y}(t)$ at all instants of time $0 \leq t$,

*agreeing with the first equation of energy conservation,

*denoting the time instants which correspond to the heights $h$ and $\tilde{h}$ by $t_1$ and $t_2$ respectively and denoting the time-varying (in general) magnitude of the tension force in the rope by $T(t)$,

we have on applying the work-energy theorem calculated using the primed frame that
$$\int_{t_1}^{t_2} T(t) (u^{'}_{1x}(t) - u^{'}_{2y}(t)) \; dt = \int_{t_1}^{t_2} T(t) ((u_{1x}(t) - v) - u^{}_{2y}(t)) \; dt \\= - v \cdot \int_{t_1}^{t_2} T(t) dt = - m_1 \tilde{u}^{'}_{1x} v + m_1 {u}^{'}_{1x} v = m_1 ({u}^{'}_{1x} - \tilde{u}^{'}_{1x}) v \leq 0,$$ in the case that $0 \leq v$, thus resulting in the equality $\int_{t_1}^{t_2} T(t) \; dt = m_1 (\tilde{u}^{'}_{1x} - {u}^{'}_{1x})$. Applying Newton's second law of motion to the mass $m_1$ which implies that $T(t) = m_1 a_{1x}$ where $a_{1x} := \dot{u}^{'}_{1x}$, we can obtain and thus verify the equality by integrating the equation of motion to obtain the change in linear momentum as $\int_{t_1}^{t_2} T(t) \; dt = m_1 \cdot \int_{t_1}^{t_2} \dot{u}^{'}_{1x}(t) \; dt = m_1 (\tilde{u}^{'}_{1x} - {u}^{'}_{1x})$.
The understanding emphasized by the apparent contradiction posed by the OP and the explanation provided above is that the tension force is in general non-conservative and the mechanical energy conservation equation cannot be applied to systems with non-conservative forces. However, we could neglect writing the contribution of the the work done by the tension force following from the work-energy theorem when using the original unprimed reference frame because the relationship $u_{1x}(t) = u_{2y}(t)$ for all $0 \leq t$ observed when using that reference frame causes the work done by the tension force to become trivial as $\int_{t_1}^{t_2} T(t) (u_{1x}(t) - u_{2y}(t)) \; dt \equiv 0$. Thus, in the special case of the mechanism considered in the post, the mechanical energy conservation equation turned out to be mathematically valid despite the presence of non-conservative forces due to the availability of the unique choice of the reference frame. This unique choice of the reference frame is the frame which is stationary w.r.t. the pulley and leads to the equality of the speeds of the two masses on applying the constraint of the rope length being constant since $x_1 - y_1 = \textit{length of rope} = \textit{constant}$ implies $\dot{x}_1 - \dot{y_2} = 0 = u_{1x} - u_{2y}$, where $x_1$ denotes the $X$ coordinate of $m_1$ and $y_2$ denotes the $Y$ coordinate of $m_2$ (easily observed by assuming the pulley pivot point to be the origin, although the choice of any point in the $XY$ plane which is above the initial height of $m_1$ as the origin leads to the same conclusion).

Mechanical energy of a system of particles depends on the velocity and acceleration of the reference frame used to calculate it. Although the mechanical energy conservation is not true for systems in which non-conservative forces are applied to (at least) some of the particles of the system, the work-energy theorem is in general always applicable.

A: Your equation for the primed frame is not correct. If you take the equation for the unprimed frame and apply the Galilei transformation you get
$$\frac{1}{2} m_1 {u'_{1x}}^2 + \frac{1}{2}m_2 {u'_{2y}}^2 + m_1 u'_{1x}v +  m_2 gh = \frac{1}{2} m_1 {\widetilde{u}'_{1x}}^2 + \frac{1}{2}m_2 {\widetilde{u}'_{2y}}^2 +  m_1 \widetilde{u}'_{1x} v+ m_2 g \widetilde{h}$$
(I dropped here a constant term $\frac{1}{2} (m_1+m_2) v^2$ on both sides of the equation which you could identify as the kinetic energy of the whole system due the motion of the primed reference frame).
So the 'cross-terms' $m_1 u'_{1x}v$ and  $m_1 \widetilde{u}'_{1x} v$ should be already present for the primed energy conservation equation in the first place. And if you do the inverse transformation on this, you obtain the initial (unprimed) equation again (that is without those 'cross-terms') as required.
The reason for this is simply that the kinetic energy is a quadratic function of the velocity and thus the energy conservation equation is not covariant under a Galilei transformation and you have these cross terms appearing (unless all masses have zero velocity in the unprimed frame, which is not possible in this case as they are accelerated).
However, the above equation holds for arbitrary values of the velocities of the masses and does not take the specific constraint here into account, which is
$u_{1x}=u_{2y}$ and $\widetilde{u}_{1x}=\widetilde{u}_{2y}$
If you insert this into your initial unprimed equation you get
$$\frac{1}{2}(m_1+m_2) u_{2y}^2 + m_2g\:h = \frac{1}{2}(m_1+m_2) \widetilde{u}_{2y}^2 + m_2 g \:\widetilde{h}.$$
This equation is obviously not affected at all by a Galilei transformation along the x-axis as it only depends on $u_{2y}$.
It effectively describes the vertical freefall of a body with gravitational mass $m_2$ but inertial mass $m_1+m_2$
And if you solve this for $\widetilde{u}_{2y}^2$ you find
$$\widetilde{u}_{2y}^2= u_{2y}^2+\frac{2m_2g\:(h-\widetilde{h})}{m_1+m_2}$$
The tension of the string is no issue here at all as it does not extend and therefore no work goes into it (as claimed in the other answer). The two masses are effectively one mass here, only that its inertial mass is different from its gravitational mass.
