I think that the answer perhaps has two aspects to it.
The Tokugawa era was a time of great change; during this era, Japan created an urban merchant class, and was, albeit, at a very slow rate, importing knowledge from the Dutch. At the same time, there are very clear trends, despite the efforts of the Tokugawa shogunate, of the transition from a feudal economy to a capitalist economy. At the same time, however, by the late Tokugawa era, the decline of the Shogun's power and the trend towards direct reverence of the Emperor was also clear, especially during major food crises and crop failures, and as a general trend of the development of nativist (essentially, proto-Japanese nationalist) schools of thought. Probably most important to remember is that fundamentally, however, the Shogunate was a reactionary, feudal, military monarchy whose greatest goal was the preservation of their reactionary, feudal system.
But there's essentially nothing you can do to eventually butterfly the "opening up" of Japan, and to preserve some element of reform, that's probably necessary anyhow. Once that happens, the survival of the shogunate depends largely on how they react towards the West. Historically, a large part of their eventual unpopularity stemmed primarily from the fact that the shogunate, because of their inability to prevent what was perceived as significant violations of Japanese sovereignty, including the eventual stationing of Western troops on Japanese soil, and the dictating of Japanese policy by the west, was perceived as weak and thus, in need of replacement.
If, on the other hand, the shogunate adopts a hardline policy against westerners (which isn't that hard; it was, in fact their policy until the appearance of Perry's ships to fire on any Western ships which appeared, under the logic that "In Western countries, ports are closed to ships of countries with whom the country lacks formal diplomatic relations; We do not have formal diplomatic relations with any Western country; In Western countries, ships are thus shown not to be welcome by firing on them; Therefore, we will fire on any Western ships that appear near our waters. Perry's ships, though, rather baldly showed that to do so would be national suicide).
The problem is, if the Japanese did anything like trying to fire on Perry, the only tangible result would be that Edo would be a smoking ruin, and anyone else who showed up would show up with the intent to negotiate aggressively. Even though not "caving" in to the West might pre-empt the Sonno Joi movement, being slapped around militarily by the West (which did happen OTL, albeit in small incidents) was not likely to do wonders for Japan's international standing, not to mention domestic opinion of the Shogunate for having let such a thing happen in the first place.
So basically, the fundamental problem standing with a reformist Tokugawa, or a Tokugawa survival, is that the Tokugawa state was totally rotten, inefficient, and obsolete, and what was really badly needed was some fundamental reform, but any system at the time needed to give something to the West, and that was not like to make the people love them, for the perceived national humiliation. So the Shogunate was also in the wrong place at the wrong time, and that's not like to help them either.