convert both PepperIdleMonitor and PepperState to IMP-chain swizzling - #532
Open
cdillard-NewRelic wants to merge 4 commits into
Open
convert both PepperIdleMonitor and PepperState to IMP-chain swizzling#532cdillard-NewRelic wants to merge 4 commits into
cdillard-NewRelic wants to merge 4 commits into
Conversation
Fix
- dylib/bridge/PepperVCLifecycleSwizzle.swift (new) — shared IMP-chain swizzle helper for (Bool) -> Void UIViewController lifecycle methods. Captures original IMP via
method_getImplementation, installs wrapper via method_setImplementation + imp_implementationWithBlock. Never renames the selector, so _cmd stays intact across the chain.
- dylib/bridge/PepperIdleMonitor.swift — install() now calls PepperVCLifecycleSwizzle.install(selector: viewWillAppear:) { vc, _ in … }. Removed swizzleMethod helper and the
@objc pepper_viewWillAppear(_:) extension on UIViewController.
- dylib/bridge/PepperState.swift — same treatment for viewDidAppear: and viewDidDisappear:. Removed static swizzleMethod helper and both @objc pepper_viewDid… extension
methods.
Why it fixes NRMA
NRMA's NRMA__beginMethod assumes _cmd equals the selector its handler was originally attached to (NRMAMethodProfiler.m:960, then throws at :988 if NRMAMethodOverride_<cmd>:
lookup fails). The old exchange pattern left NRMA's handler IMP reachable via pepper_viewWillAppear:, so the recursive self-selector call handed NRMA the wrong _cmd → lookup
missed → NRInvalidArgumentException → SIGABRT. IMP chaining never creates that alternate selector entry, so _cmd is always viewWillAppear: regardless of load order.
Author
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix
method_getImplementation, installs wrapper via method_setImplementation + imp_implementationWithBlock. Never renames the selector, so _cmd stays intact across the chain.
@objc pepper_viewWillAppear(_:) extension on UIViewController.
methods.
Why it fixes NRMA
NRMA's NRMA__beginMethod assumes cmd equals the selector its handler was originally attached to (NRMAMethodProfiler.m:960, then throws at :988 if NRMAMethodOverride:
lookup fails). The old exchange pattern left NRMA's handler IMP reachable via pepper_viewWillAppear:, so the recursive self-selector call handed NRMA the wrong _cmd → lookup
missed → NRInvalidArgumentException → SIGABRT. IMP chaining never creates that alternate selector entry, so _cmd is always viewWillAppear: regardless of load order.