Strictly, the outbreak of war does not necessarily lead to termination or suspension of treaty obligations. Many treaties are intended to be binding especially in times of war (see the Annex to the Draft Articles on the Effect of Armed Conflicts on Treaties).
However, sometimes, wartime suspension of treaty obligations is provided for in the treaty itself. For example, the American Convention on Human Rights, Art. 27 says:
In time of war, public danger, or other emergency that threatens the
independence or security of a State Party, it may take measures derogating from its obligations under
the present Convention to the extent and for the period of time strictly required by the exigencies of
the situation, provided that such measures are not inconsistent with its other obligations under
international law and do not involve discrimination on the ground of race, color, sex, language,
religion, or social origin.
Some Articles of the American Convention are exempted from that general suspension clause.
Even for treaties without an express suspension clause, in practice, states are often given the leeway to suspend performance until the end of hostilities. See James Crawford, ed. Brownlie's Principles of Public International Law, 9th ed. (2019) p. 376:
in practice many types of
treaty are regarded as at least suspended in time of war, and war conditions may lead to
termination of treaties on grounds of impossibility or fundamental change of circumstances.
You also mention the circumstance where a party "could not comply" with its obligations. This raises the ground of impossibility. See Art. 61 of the Vienna Convention on the Law of Treaties:
A party may invoke the impossibility of performing a treaty as a ground for terminating or
withdrawing from it if the impossibility results from the permanent disappearance or destruction of an
object indispensable for the execution of the treaty. If the impossibility is temporary, it may be invoked
only as a ground for suspending the operation of the treaty.
Impossibility of performance may not be invoked by a party as a ground for terminating,
withdrawing from or suspending the operation of a treaty if the impossibility is the result of a breach by
that party either of an obligation under the treaty or of any other international obligation owed to any
other party to the treaty.
Given the uncertain state of the law on this issue, the International Law Commission has worked to produce draft articles and commentary that would deal with the effect of armed conflicts on treaties. This is the product of extensive research, academic writing, and judicial decisions from national and international courts, all cited in the footnotes.