Closed simpzan closed 7 years ago
Thanks for the stack trace. Is the file watcher on?
It's off.
On Sun, Feb 5, 2017 at 9:23 PM, John Holdsworth notifications@github.com wrote:
Thanks for the stack trace. Is the file watcher on?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/johnno1962/injectionforxcode/issues/200#issuecomment-277519529, or mute the thread https://github.com/notifications/unsubscribe-auth/AAWX8pJESvDjSAHR-5AFLR26-jGpLYVlks5rZc1AgaJpZM4L3d-1 .
Odd, crash is realted to file watcher being on :S
10 com.apple.Foundation 0x00007fff964e6f84 -[NSRegularExpression(NSMatching) enumerateMatchesInString:options:range:usingBlock:] + 218
11 com.apple.Foundation 0x00007fff9657e0d2 -[NSRegularExpression(NSMatching) rangeOfFirstMatchInString:options:range:] + 139
12 com.johnholdsworth.Injectorator Injection-[INPluginMenuController enableFileWatcher:] + 396 at INPluginMenuController.m:455 13 com.johnholdsworth.Injectorator Injection
@objc Injection.INController.enableFileWatcher (Swift.Bool) -> () + 110 at INController.swift
14 com.johnholdsworth.Injectorator Injection-[INPluginClientController setConnection:] + 1757 at INPluginClientController.m:245 15 com.johnholdsworth.Injectorator Injection
-[INPluginMenuController backgroundConnectionService] + 269 at INPluginMenuController.m:583
- (void)enableFileWatcher:(BOOL)enabled {
[self.docTile
performSelectorOnMainThread:@selector(setBadgeLabel:)
withObject:enabled?@"1":nil waitUntilDone:NO];
if ( enabled && self.watchButton.state ) {
if ( !self.fileWatcher ) {
static NSRegularExpression *regexp;
if ( !regexp )
regexp = [[NSRegularExpression alloc] initWithPattern:@"^(.+?/([^/]+))/(([^/]*)\\.(xcodeproj|xcworkspace|(idea/misc.xml)))" options:0 error:nil];
NSString *workspacePath = [self workspacePath];
NSRange range = [regexp rangeOfFirstMatchInString:workspacePath options:0
range:NSMakeRange( 0, workspacePath.length )];
NSString *projectRoot = [[workspacePath substringWithRange:range] stringByDeletingLastPathComponent];
INJECTION_RELEASE( self.fileWatcher = [[FileWatcher alloc] initWithRoot:projectRoot plugin:^( NSArray *filesChanged ) {
NSString *filePath = filesChanged[0];
NSTimeInterval now = [NSDate timeIntervalSinceReferenceDate];
NSTimeInterval timeSinceLifeLastInjected = self.lastInjected[filePath] ?
now - self.lastInjected[filePath].timeIntervalSinceReferenceDate : 1000.;
if ( --skipLastSaved < 0 && now - lastChanged > MIN_CHANGE_INTERVAL &&
timeSinceLifeLastInjected > MIN_CHANGE_INTERVAL ) {
self.lastFile = filePath;
self.hasSaved = YES;
[self injectSource:self];
lastChanged = now;
}
}] );
}
}
else
self.fileWatcher = nil;
}
Ok, I just reproduced the issue. you are right. It is related to file watcher.
If I check on file watcher, then start the client app, it crashes, and after restart, the file watcher is not checked any more, but it still crashes every time client app starts up.
Then I check on file watcher, then check it off. It will not crash any more.
On Sun, Feb 5, 2017 at 9:31 PM, John Holdsworth notifications@github.com wrote:
Odd, crash is realted to file watcher being on: 10 com.apple.Foundation 0x00007fff964e6f84 -[NSRegularExpression(NSMatching) enumerateMatchesInString:options:range:usingBlock:] + 218 11 com.apple.Foundation 0x00007fff9657e0d2 -[NSRegularExpression(NSMatching) rangeOfFirstMatchInString:options:range:] + 139 12 com.johnholdsworth.Injectorator Injection-[INPluginMenuController enableFileWatcher:] + 396 at INPluginMenuController.m:455 13 com.johnholdsworth.Injectorator Injection@objc https://github.com/objc Injection.INController.enableFileWatcher (Swift.Bool) -> () + 110 at INController.swift 14 com.johnholdsworth.Injectorator Injection-[INPluginClientController setConnection:] + 1757 at INPluginClientController.m:245 15 com.johnholdsworth.Injectorator Injection-[INPluginMenuController backgroundConnectionService] + 269 at INPluginMenuController.m:583
(void)enableFileWatcher:(BOOL)enabled { [self.docTile performSelectorOnMainThread:@selector(setBadgeLabel:) withObject:enabled?@"1":nil waitUntilDone:NO];
if ( enabled && self.watchButton.state ) { if ( !self.fileWatcher ) { static NSRegularExpression regexp; if ( !regexp ) regexp = [[NSRegularExpression alloc] initWithPattern:@"^(.+?/([^/]+))/(([^/])\.(xcodeproj|xcworkspace|(idea/misc.xml)))" options:0 error:nil];
NSString *workspacePath = [self workspacePath]; NSRange range = [regexp rangeOfFirstMatchInString:workspacePath options:0 range:NSMakeRange( 0, workspacePath.length )]; NSString *projectRoot = [[workspacePath substringWithRange:range] stringByDeletingLastPathComponent]; INJECTION_RELEASE( self.fileWatcher = [[FileWatcher alloc] initWithRoot:projectRoot plugin:^( NSArray *filesChanged ) { NSString *filePath = filesChanged[0]; NSTimeInterval now = [NSDate timeIntervalSinceReferenceDate]; NSTimeInterval timeSinceLifeLastInjected = self.lastInjected[filePath] ? now - self.lastInjected[filePath].timeIntervalSinceReferenceDate : 1000.; if ( --skipLastSaved < 0 && now - lastChanged > MIN_CHANGE_INTERVAL && timeSinceLifeLastInjected > MIN_CHANGE_INTERVAL ) { self.lastFile = filePath; self.hasSaved = YES; [self injectSource:self]; lastChanged = now; } }] ); }
} else self.fileWatcher = nil; }
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/johnno1962/injectionforxcode/issues/200#issuecomment-277519995, or mute the thread https://github.com/notifications/unsubscribe-auth/AAWX8qVgMoIdsLuCuYCkcP9M2OU0_Pwvks5rZc9NgaJpZM4L3d-1 .
I can see why the flag get’s out of sync but the real problem is probably workspacePath is nil. Can you run Injection.app/Contents/MacOS/Injection from the console and see what it prints out please?
2017-02-05 22:36:02.355 Injection[71606:2011262] {\rtf1\ansi\def0}
2017-02-05 22:36:02.357 Injection[71606:2011326] Injection: Waiting for connections...
2017-02-05 22:36:02.365 Injection[71606:2011328] XprobeConsole: Waiting for connections...
2017-02-05 22:36:04.225 Injection[71606:2011262] Bartender: Loaded BartenderHelperTwoOneTwo
2017-02-05 22:36:25.587 Injection[71606:2011326] Injection: Connection from 127.0.0.1:5090
2017-02-05 22:36:25.588 Injection[71606:2011262] Connection from: /Users/simpzan/Library/Developer/Xcode/DerivedData/SpechtLite-bwlylqcyhfhhhafzxrbaedfhoxvc/Build/Products/Debug/SpechtLite.app/Contents/MacOS/SpechtLite x86_64 (18)
2017-02-05 22:36:25.592 Injection[71606:2011326] An uncaught exception was raised
2017-02-05 22:36:25.592 Injection[71606:2011326] *** -[NSRegularExpression enumerateMatchesInString:options:range:usingBlock:]: nil argument
2017-02-05 22:36:25.593 Injection[71606:2011326] (
0 CoreFoundation 0x00007fff91c94452 __exceptionPreprocess + 178
1 libobjc.A.dylib 0x00007fff96b45f7e objc_exception_throw + 48
2 CoreFoundation 0x00007fff91cfb41d +[NSException raise:format:] + 205
3 Foundation 0x00007fff964e6f84 -[NSRegularExpression(NSMatching) enumerateMatchesInString:options:range:usingBlock:] + 218
4 Foundation 0x00007fff9657e0d2 -[NSRegularExpression(NSMatching) rangeOfFirstMatchInString:options:range:] + 139
5 Injection 0x000000010f522adc Injection + 43740
6 Injection 0x000000010f5937ae Injection + 505774
7 Injection 0x000000010f51ad98 Injection + 11672
8 Injection 0x000000010f523294 Injection + 45716
9 Foundation 0x00007fff964f2e64 __NSThread__start__ + 1351
10 libsystem_pthread.dylib 0x00007fff922fc99d _pthread_body + 131
11 libsystem_pthread.dylib 0x00007fff922fc91a _pthread_body + 0
12 libsystem_pthread.dylib 0x00007fff922fa351 thread_start + 13
)
2017-02-05 22:36:25.593 Injection[71606:2011326] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSRegularExpression enumerateMatchesInString:options:range:usingBlock:]: nil argument'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff91c94452 __exceptionPreprocess + 178
1 libobjc.A.dylib 0x00007fff96b45f7e objc_exception_throw + 48
2 CoreFoundation 0x00007fff91cfb41d +[NSException raise:format:] + 205
3 Foundation 0x00007fff964e6f84 -[NSRegularExpression(NSMatching) enumerateMatchesInString:options:range:usingBlock:] + 218
4 Foundation 0x00007fff9657e0d2 -[NSRegularExpression(NSMatching) rangeOfFirstMatchInString:options:range:] + 139
5 Injection 0x000000010f522adc Injection + 43740
6 Injection 0x000000010f5937ae Injection + 505774
7 Injection 0x000000010f51ad98 Injection + 11672
8 Injection 0x000000010f523294 Injection + 45716
9 Foundation 0x00007fff964f2e64 __NSThread__start__ + 1351
10 libsystem_pthread.dylib 0x00007fff922fc99d _pthread_body + 131
11 libsystem_pthread.dylib 0x00007fff922fc91a _pthread_body + 0
12 libsystem_pthread.dylib 0x00007fff922fa351 thread_start + 13
)
libc++abi.dylib: terminating with uncaught exception of type NSException
If not licensed, this copy will expire on: 2017-02-26 12:48:43 +0000 1488113323.50831
I think I know what the problem is here and have uploaded a new version 2.1 if you want to give it a try. http://johnholdsworth.com/injection.html
it has been fixed. Thank you!
Thanks for taking the time to file the report 👍
my honor! :) and thank you for making and sharing this wonderful tool!
Hi, there!
I found that the injected()
method will not be called when doing injection in 2.1 version.
Seems to be working this end. Are you sure?
https://github.com/simpzan/Escalade/blob/master/Escalade-macOS/MainMenuController.swift#L31-L36
this is my code, and when I click inject source
, I only got the first print.
2017-02-08 18:36:40.874 Escalade-macOS[98993:3010692] +[BundleInjection load] 10.126.52.103 (see project's main.(m|mm)
2017-02-08 18:36:40.879 Escalade-macOS[98993:3010724] Injection attempting connection to: 127.0.0.1:31452
2017-02-08 18:36:40.882 Escalade-macOS[98993:3010724] Connected to "Injection" plugin, ready to load x86_64 code.
2017-02-08 18:36:42.372 Escalade-macOS[98993:3010692] Bartender: Loaded BartenderHelperTwoOneTwo
Compiling /Users/simpzan/repo/Escalade/Escalade-macOS/MainMenuController.swift
objc[98993]: Class _TtC14Escalade_macOS18MainMenuController is implemented in both /Users/simpzan/Library/Developer/Xcode/DerivedData/Escalade-dpcigypuvdmvriaglusxdxoytjxm/Build/Products/Debug/Escalade-macOS.app/Contents/MacOS/Escalade-macOS and /Users/simpzan/Library/Developer/Xcode/DerivedData/Escalade-dpcigypuvdmvriaglusxdxoytjxm/Build/Products/Debug/Escalade-macOS.app/Contents/InjectionBundle2.bundle/Contents/MacOS/InjectionBundle. One of the two will be used. Which one is undefined.
28 injections performed so far.
2017-02-08 18:36:45.814 Escalade-macOS[98993:3010692] Ignore any warning, Swizzled Escalade_macOS.MainMenuController 0x1058edac8 -> 0x100013540
I've been injected+: MainMenuController
Are you saying this worked before and not in the new version? Instance level injected() is tricky to implement. There needs to be a path from the AppDelegate and and windows in the app to the instance you are injecting for it to locate objects to message.
I got the instance injected()
working in another project at the first
attempt. But failed to get it work in this new project.
Now I get it. Formerly, the object is only in the MainWindow.xib.
I just add a reference to the object in AppDelegate obj, the - injected
works now. :)
Thank you for the clarification and support!
On Wed, Feb 8, 2017 at 7:35 PM, John Holdsworth notifications@github.com wrote:
Are you saying this worked before and not in the new version? Instance level injected() is tricky to implement. There needs to be a path from the AppDelegate and and windows in the app to the instance you are injecting for it to locate objects to message.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/johnno1962/injectionforxcode/issues/200#issuecomment-278304102, or mute the thread https://github.com/notifications/unsubscribe-auth/AAWX8gx89jcZqfe5HroGcu9IavBIfjzvks5raaiKgaJpZM4L3d-1 .