Skip to content
This repository has been archived by the owner on Dec 29, 2020. It is now read-only.

REM-24817 Fix swizzle crash when there is no original method #16

Merged

Conversation

donnie-jp
Copy link
Contributor

  • store a NULL NSValue as the original implementation if there wasn't an original method
  • use a concatenation of the class name and method selector as the map key
  • swizzle the WKWebView delegate before calling the original method because WebKit appears to save a list of the delegate selectors that the delegate can respond to at the time of the setDelegate: call. Without this change the swizzling won’t work on the initial WKWebView load
  • remove mistakenly committed swizzle else clause

Verified in example app on iOS 11 simulator

…swizzle gets added twice

- store a NULL NSValue as the original implementation if there wasn't an original method
- use a concatenation of the class name and method selector as the map key
- swizzle the WKWebView delegate before calling the original method because WebKit appears to save a list of the delegate selectors that the delegate can respond to at the time of the setDelegate: call. Without this change the swizzling won’t work on the initial WebView load
- remove mistakenly committed swizzle else clause
@codecov-io
Copy link

Codecov Report

❗ No coverage uploaded for pull request base (master@4c9260c). Click here to learn what that means.
The diff coverage is 92.59%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master      #16   +/-   ##
=========================================
  Coverage          ?   81.27%           
=========================================
  Files             ?       30           
  Lines             ?     1207           
  Branches          ?        0           
=========================================
  Hits              ?      981           
  Misses            ?      226           
  Partials          ?        0
Impacted Files Coverage Δ
...PerformanceTracking/Private/_RPTClassManipulator.m 54.36% <100%> (ø)
...eTracking/Private/_RPTClassManipulator+WKWebView.m 84.93% <83.33%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4c9260c...7034076. Read the comment docs.

Copy link
Contributor

@vito1188 vito1188 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approved

@donnie-jp donnie-jp merged commit d906001 into rakutentech:master Dec 22, 2017
donnie-jp pushed a commit to donnie-jp/ios-perftracking that referenced this pull request Dec 14, 2018
…~SHIVAIAH.MAHESHA/alpha-ios-perftracking:REM-20701 to master

* commit '87cdbfeeda486444fd493cdb86896f5c050d93e7':
  Code Review Comments
  Code Review comments/Adding more tests
  [REM-20701][iOS][Perf] Write unit tests for RingBuffer class
donnie-jp pushed a commit to donnie-jp/ios-perftracking that referenced this pull request Dec 14, 2018
…TH/perftracking_ds:release/1.1-merge-from-gh-20180130 to master

* commit 'dcfd3ee904abb3f238e296aea80297d9e5e7f95e':
  REM-25612 bump podspec for 1.1 release (rakutentech#25)
  feat(swizzling): REM-25021 Rewrite NSURLSessionTask swizzling (rakutentech#24)
  [REM-25203] Apply selector-preserving method swizzling to UIControl/UICollectionViewCell/UITableViewCell.
  [REM-25202] [iOS][Perf] Apply selector-preserving method swizzling to UIViewController.
  [REM-25200] Apply selector-preserving method swizzling to UIWebView (rakutentech#21)
  REM-25339 Add RPTForceTrackingEnabled usage description to README (rakutentech#20)
  REM-25345 Add tests for implementationWithBlock swizzling (rakutentech#19)
  REM-24817 Fix swizzle crash when there is no original method and the swizzle gets added twice (rakutentech#16)
  REM-25242 Fix redirect handling in custom protocol (rakutentech#15)
  REM-25138 Debug builds should always send performance data if config API response is valid (rakutentech#12)
  feat(swizzling): REM-24817 Rewrite WKWebView swizzling (rakutentech#14)
  REM-25817 Fix crash that occurs when info.plist keys are missing by failing safely in release builds (rakutentech#13)
  REM-25128 Prepare for publishing to CocoaPods (rakutentech#10)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants