Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running Xcode Generated UITest Crashes on eDistantObject`SetupBlockInvocationForward #1187

Open
kelliepersson opened this issue Feb 7, 2020 · 17 comments

Comments

@kelliepersson
Copy link

  1. Add EG2UITests UI Testing Bundle to our project
  2. Add Pod file changes:
    pod 'EarlGreyApp' (added to app target definition)
    
    target 'EG2UITests' do
        pod 'EarlGreyTest'
        pod 'iOSSnapshotTestCase'
        test_pods
    end
  1. Run pod install
  2. Run (generated) UI Test
  3. App crashes on launch:
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = step over
  * frame #0: 0x000000012a198324 eDistantObject`SetupBlockInvocationForward at NSBlock+EDOInvocation.m:49:5
    frame #1: 0x00000001075bf3a7 dyld_sim`ImageLoaderMachO::doModInitFunctions(ImageLoader::LinkContext const&) + 517
    frame #2: 0x00000001075bf7b8 dyld_sim`ImageLoaderMachO::doInitialization(ImageLoader::LinkContext const&) + 40
    frame #3: 0x00000001075ba9a2 dyld_sim`ImageLoader::recursiveInitialization(ImageLoader::LinkContext const&, unsigned int, char const*, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) + 456
    frame #4: 0x00000001075ba90f dyld_sim`ImageLoader::recursiveInitialization(ImageLoader::LinkContext const&, unsigned int, char const*, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) + 309
    frame #5: 0x00000001075ba90f dyld_sim`ImageLoader::recursiveInitialization(ImageLoader::LinkContext const&, unsigned int, char const*, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) + 309
    frame #6: 0x00000001075b97a6 dyld_sim`ImageLoader::processInitializers(ImageLoader::LinkContext const&, unsigned int, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) + 188
    frame #7: 0x00000001075b9846 dyld_sim`ImageLoader::runInitializers(ImageLoader::LinkContext const&, ImageLoader::InitializerTimingList&) + 82
    frame #8: 0x00000001075b10f1 dyld_sim`dyld::runInitializers(ImageLoader*) + 82
    frame #9: 0x00000001075b501e dyld_sim`dlopen_internal + 909
    frame #10: 0x000000010db109d9 libdyld.dylib`dlopen + 171
    frame #11: 0x00000001081cc7a7 CoreFoundation`_CFBundleDlfcnLoadBundle + 151
    frame #12: 0x0000000108099302 CoreFoundation`_CFBundleLoadExecutableAndReturnError + 274
    frame #13: 0x0000000107a3021a Foundation`-[NSBundle loadAndReturnError:] + 356
    frame #14: 0x0000000107906184 XCTest`_XCTestMain + 1508
    frame #15: 0x000000010759dedd EG2UITests-Runner`_XCTRunnerRunTests + 258
    frame #16: 0x000000010759dddb EG2UITests-Runner`__67-[_XCTRunnerAppDelegate application:didFinishLaunchingWithOptions:]_block_invoke + 9
    frame #17: 0x000000010811f29c CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
    frame #18: 0x000000010811ea08 CoreFoundation`__CFRunLoopDoBlocks + 312
    frame #19: 0x0000000108119894 CoreFoundation`__CFRunLoopRun + 1284
    frame #20: 0x0000000108119066 CoreFoundation`CFRunLoopRunSpecific + 438
    frame #21: 0x000000011179fbb0 GraphicsServices`GSEventRunModal + 65
    frame #22: 0x000000010a27cd4d UIKitCore`UIApplicationMain + 1621
    frame #23: 0x000000010759e098 EG2UITests-Runner`main + 183
    frame #24: 0x000000010db0cc25 libdyld.dylib`start + 1
@kelliepersson
Copy link
Author

Downgrading to eDistantObject 0.9.0 as suggested in this seemingly similar issue did not work.

@AlbertWang0116
Copy link
Collaborator

Kellie, which xcode version are your tests built?

@kelliepersson
Copy link
Author

Albert, I am running Xcode version: Version 11.3.1 (11C504)

@AlbertWang0116
Copy link
Collaborator

Sorry for the latency. It is likely to be the dependency corruption at EarlGrey podspec. Could you check your Podfile.lock (auto generated beside your Podfile after pod install) that if the eDistantObject version is 0.9.1? If that's the case, try changing it back to 0.9.0 and rerun the test (this was how I make Demo/EarlGreyExample work).

@kelliepersson
Copy link
Author

I will check the Podfile and update if this resolves the issue. Thanks so much @AlbertWang0116

@kelliepersson
Copy link
Author

Albert, I checked the Podfile and eDistantObject version is 0.9.0.

@AlbertWang0116
Copy link
Collaborator

I see, so I guess you can run EarlGrey tests on the demo app but not on your own? From the place that error complains:
https://github.com/google/eDistantObject/blob/bf9291a29399afb4188e3454a448d7dc76be3c06/Service/Sources/NSBlock%2BEDOInvocation.m#L46

eDistantObject tries to add forwardInvocation: method into NSBlock but failed. Given it works on the demo app, it means apple doesn't implement forwardInvocation: to NSBlock by xcode 11.3.1. Do you happen to know any of your app's library does it?

@kelliepersson
Copy link
Author

Apologies for delayed response. It does not appear that any of our code or any of our 3rd party dependencies add a method called forwardInvocation: to NSBlock.

We are going to continue to investigate the issue on our end, specifically to see if we have already come through SetupBlockInvocationForward() once and thusly already added the method to NSBlock.

Will post back with an update. Thank you again @AlbertWang0116 for your help.

@AlbertWang0116
Copy link
Collaborator

Hi Kellie, any luck on this? If it truly imported eDO twice, your should be able to hit the breakpoint of that symbol twice.

@kelliepersson
Copy link
Author

Hello Albert,
I am looking at this again right now. I am stepping through now but I am not hitting the breakpoint before it crashes.

@kelliepersson
Copy link
Author

kelliepersson commented Mar 10, 2020

@AlbertWang0116 What I am noticing when stepping through the demo project is GREYTestApplicationDistantObject.load() method is called at the beginning of the test suite, establishing the test application eDistantObject. However, when I run my sample test, GREYTestApplicationDistantObject.load() is never called.

Any thoughts?

@AlbertWang0116
Copy link
Collaborator

@kelliepersson GREYTestApplicationDistantObject doesn't have load method, do you mean this one?

@tirodkar
Copy link
Collaborator

Kellie, it would be super helpful for us if you were able to create a repro case / project we could clone and test out the issue.

@kelliepersson
Copy link
Author

kelliepersson commented Mar 13, 2020

@AlbertWang0116 I was able to get passed this error/crash 😅 . We have a rather complicated Podfile setup. To prevent duplicate linkage of static libraries, I added EarlGreyApp & EarlGreyTest to a list static frameworks passed toremove_static_framework_duplicate_linkage inside Podfile

post_install do |installer_representation|
    installer_representation.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES'] = '$(inherited)'
        end
    end

    static_frameworks = [
      'EarlGreyApp',
      'EarlGreyTest'
    ]
    remove_static_framework_duplicate_linkage({
      'Framework' => static_frameworks
    })
end

remove_static_framework_duplicate_linkage as defined here

@AlbertWang0116
Copy link
Collaborator

Nice! Thanks for the update Kellie!

@StevenVerheyen
Copy link

I just want to confirm that with eDistantObject -v 1.0.0 this is still an issue. Downgrading to -v 0.9.0 did the trick for me. Is there something wrong with the 1.0.0 version? Is the setup documentation still up to date?

@AlbertWang0116
Copy link
Collaborator

Hey Steven, you need to pair the current EarlGrey version (2.0) with eDistantObject 0.9.0. We are working on releasing a new EarlGrey version which will be paired with eDistantObject 1.0.0.

Sorry for the inconvenience.

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

No branches or pull requests

4 participants