Skip to content
This repository has been archived by the owner on Jul 18, 2019. It is now read-only.

EasySIMBL doesn't load early enough in some applications #21

Open
quentinmit opened this issue Dec 12, 2014 · 2 comments
Open

EasySIMBL doesn't load early enough in some applications #21

quentinmit opened this issue Dec 12, 2014 · 2 comments

Comments

@quentinmit
Copy link

I'm trying to write a SIMBL plugin that requires method swizzling. It looks like the plugin isn't being injected until very far in the application launch process - judging from the logs, it looks like it's not injected until after the application has fully launched and even opened/reopened its document windows.

Is there any way that EasySIMBL might be able to inject plugins earlier?

@norio-nomura
Copy link
Owner

SIMBL Agent.app is using [[NSWorkspace sharedWorkspace]runningApplications] for observing application launching. For injecting EasySIMBL.osax to target application, SIMBL Agent.app will wait until isFinishedLaunching of target application will be true as following:

https://github.com/norio-nomura/EasySIMBL/blob/master/SIMBL%20Agent/SIMBLAgent.m#L100-L103

As I tested on developing earlier version of EasySIMBL, injecting did fail if the injecting message sent while isFinishedLaunching was false. isFinishedLaunching will be true on posting NSApplicationDidFinishLaunchingNotification in target application.

The notification will trigger -[NSApplicationDelegate applicationDidFinishLaunching:] in target application.
There are some overhead of injecting containers for sandboxed applications. But if I would change to reducing the overhead that SIMBL Agent.app will injecting containers before isFinishedLaunching will be true, SIMBL Agent.app will not be able to inject plugins earlier than that delegate method calling in target application.

If injecting did happen on far later timing in your target application, it may be specific issue on your target application.

@quentinmit
Copy link
Author

Looking at one particular example, NSWorkspaceWillLaunchApplicationNotification is posted at 11:15:41. NSWorkspaceDidLaunchApplicationNotification is posted 5 seconds later at 11:15:46. Then my SIMBL plugin doesn't log its first message (which happens immediately on load) until 3 seconds later, at 11:15:49. This is far too late to swizzle methods that are involved in opening the initial windows.

I noticed that there was a AppleTextInputMenuExtraDidLoadNotification posted at 11:15:43; I wonder what that is and if it could be used as an indication that we can start trying to load EasySIMBL.

I'm testing with an unsandboxed app, so it's not that.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants