December 22, 2024

Skype and MobileSubstrate Issues Explained

Posted April 5, 2009 at 11:45pm by iClarified · 22172 views
Saurik has posted a very in depth message regarding the issues users are having with Skype and MobileSubstrate. The message was posted in Cydia but you can read it below for your convenience.

-----
I keep getting a flood of e-mail from people about bugs in Skype and MobileSubstrate. There are the users who are incredibly thankful that everything is fixed, and those who are still having problems and even want to downgrade their MobileSubstrate.

This letter is to the people in the latter group, in the hope that it fully explains the problem, the correct solution, and also why MobileSubstrate looks to be a culprit at a glance (but actually isn't).

In all seriousness: MobileSubstrate is not your problem. Yes, I understand that you upgraded MobileSubstrate to 0.9.2804-1 and it worked, and you upgraded to 0.9.2805-1 and it doesn't. That does not mean that 0.9.2805-1 is your problem: debugging is a much more complicated problem than that.

MobileSubstrate is a framework that allows "extensions" to modify the code of existing "applications".

Here are some typical examples:
* WinterBoard: changes the way graphics and other files are loaded
* SBSettings: alters the status bar to drop down a useful settings panel
* Backgrounder: adds code to any program to put it in the background
* VoIPover3G: tricks programs into believing they are on WiFi (not 3G)

Doing this is somewhat tricky, as one might imagine. You have to be very careful to not disrupt the program you are extending: it is easy to break it.

The primary tool is libsubstrate (which extensions often use): it provides a couple tools to do the hard parts: it lets developers hook functions.

MobileSubstrate itself, though, doesn't do anything but load other extensions (which in turn may use libsubstrate). This makes it generally harmless.

By doing so, it can provide a layer of safety through "Mobile Safe Mode":
when extensions cause SpringBoard to crash, MobileSubstrate detects this and lets you temporarily use your device without any loaded extensions.

The goal of this is to let you safely get into Cydia and remove the buggy package: not run your device in safe mode for a performance improvement, or to annoy and irritate the user ;P.

Ok, now we have Skype: Skype is doing something very tricky in the way that it loads. It may not be the only program that does this, but it is definitely the only well known one.

Due to this weird loading mechanism, MobileSubstrate 0.9.2690-1 itself, just the extension loader, used to cause Skype to crash after you used it for a while: something in "dyld" would get used "too soon", and you'd eventually tickle it the wrong way and crash it.

When this became major news, it was 2AM and I had been travelling all day. As I wasn't in the position to fix it, I released 0.9.2804-1, the hack version people claim "works". This version simply refuses to load extensions into Skype at all: it purposesly won't work.

The next morning I then worked on actually figuring out what was wrong and then released MobileSubstrate 0.9.2805-1. This version works 100%.
Seriously, trust me: it works 100% correctly, as it should, with Skype.

What this means is that 0.9.2805-1 actually loads extensions you have installed into Skype. If any of these extensions have bugs in them (maybe even Skype-specific ones !!), then Skype isn't going to work correctly.

Downgrading MobileSubstrate, therefore, is not the correct answer: getting the broken extension fixed is.

However, the story is even more complicated even than that: now that extensions are being loaded into Skype, the Skype process is slightly more complicated than it was before: you are using both the code from Skype and from the third-parties.

Now, going back to earlier: I said that MobileSubstrate 0.9.2690-1 caused a problem with Skype that it took a while to notice: usually about 45 seconds: something had to "tickle" the problem.

Now that Skype is more complicated, you are using a lot more code, faster, and are more likely to tickle things. If you have that dyld bug you can expect even more, worse crashes.

However, I said that MobileSubstrate 0.9.2805-1 doesn't have that bug anymore, and I really was serious.

Unfortunately, not everyone actually uses MobileSubstrate to write their extensions. Some of these developers have legitimate reasons (mAdvLock), and some just don't (IntelliScreen).

So, these few non-MobileSubstrate extensions are causing (and always did) the same underlying problem that MobileSubstrate did before: they are destabilizing dyld in such a way that Skype later crashes. The symptom looks different, however, as now extensions are tickling different things.

Due to this, I'm flooded with reports that random things are broken: everything from MobileSubstrate to Better Tap to Unlock (which seems so unrelated to this problem it hurts ;P). Someone even "isolated" this problem to using some WinterBoard themes.

However, that should seem very unlikely: as complicated as Skype may be, it is just another program. It loads weirdly, so MobileSubstrate did need to be updated, but all of the extensions you use every day should not randomly stop working; in fact, they are not the source of the bug.

Therefore, Uninstalling or dowgrading MobileSubstrate, or removing specific extensions, may look like it helps, but you are just punting the problem to some less noticeable corner of Skype by jettisoning your loaded extensions.

The only correct fix for these bugs you are having then needs to come from the vendors of non-MobileSustrate based extensions: not from me.

So, now we know A) why this is all happening (loading code too early corrupts dyld) and B) why it looked like it worked before you upgraded MobileSubstrate (the bug was always there, but a more complex program means you notice it sooner).

Here is a list of currently known non-MobileSubstrate based extensions. I have so far not found a single user for whom removing all of these packages did not fix the problem; but, there may very well be more of these in Cydia.

* IntelliScreen
* mAdvLock
* mCoolPhone
* MobileHook
* MobileLog/iLog
* Rock Extensions

If you don't want to uninstall these packages, then you should contact their respective developers to get them fixed and updated for Skype.

Really, they should be modified to use MobileSubstrate's loader. That way they will not only work with Skype, but as I release upgrades to fix any issues in the future (and as you can see from my response time on Skype: I care) they will continue to work correctly.

This is as simple as linking their .dylib into the DynamicLibraries folder, rather than putting their own entry into SpringBoard: it seriously should not take longer than five minutes to fix.

In fact, this is so simple, users with some small amount of technical knowledge can do this themselves. It doesn't even require the original developers to make these fixes.

Even more to the point, as I find this situation incredibly bothersome, if there is sufficient demand for it I may release a tool that retrofits these extensions to use MobileSubstrate.

I don't, however, believe that is a correct solution to this problem. (Also, I'm not certain when I'd have time to get around to writing it :(.)
-----