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

Xcode 13 ASLoadFrameworkInitializer dead lock fix on running unit test #2032

Merged
merged 7 commits into from Dec 3, 2021

Conversation

GeekTree0101
Copy link
Contributor

@GeekTree0101 GeekTree0101 commented Sep 28, 2021

Separated before & after main for fix dead lock issue running unit test

a366b40

void ASInitializeFrameworkMainThread(void)
{
  static dispatch_once_t onceToken;
  dispatch_once(&onceToken, ^{
    ASDisplayNodeCAssertMainThread();
    // Ensure these values are cached on the main thread before needed in the background.
    if (ASActivateExperimentalFeature(ASExperimentalLayerDefaults)) {
      // Nop. We will gather default values on-demand in ASDefaultAllowsGroupOpacity and ASDefaultAllowsEdgeAntialiasing
    } else {
      CALayer *layer = [[[UIView alloc] init] layer]; // <--- dead lock here on before main
      allowsGroupOpacityFromUIKitOrNil = @(layer.allowsGroupOpacity);
      allowsEdgeAntialiasingFromUIKitOrNil = @(layer.allowsEdgeAntialiasing);
    }
    ASNotifyInitialized();
#if AS_SIGNPOST_ENABLE
    _ASInitializeSignpostObservers();
#endif
  });
}

initialSetNeedsDisplayCount should be called once

28d8706

Loaded node of contentsScale must be 2.0 on layer backed

01e47e3
Creating layers (not created via a UIView), node need to set their scale manually. Usually this is just layer.contentsScale = [[UIScreen mainScreen] scale].

@GeekTree0101 GeekTree0101 changed the title Xcode 13 ASLoadFrameworkInitializer dead lock fix during Unit Test executation on before main: Xcode 13 ASLoadFrameworkInitializer dead lock fix on running unit test Sep 28, 2021
@GeekTree0101

This comment has been minimized.

@mikolasB
Copy link

May i ask whats blocking progress here? Meanwhile Xcode 13.1 is just around the corner.

@GeekTree0101
Copy link
Contributor Author

I'm also curious too

@frugoman
Copy link

Anything needed to be done to have this merged?

@genry86
Copy link

genry86 commented Oct 25, 2021

Any progress?

@mikolasB
Copy link

@nguyenhuy @rcancro please have a look here 🙏

@mattrobmattrob
Copy link

ASInitializeFrameworkMainThreadOnDestructor is not called until the program ceases execution (for example when the entire test suite that depends on this framework is tearing down). I think this is an undesired change in functionality given this is for initialization.

With a breakpoint in ASInitializeFrameworkMainThreadOnDestructor:

...
Test Suite 'All tests' passed at 2021-10-26 15:47:28.754.
	 Executed 13 tests, with 0 failures (0 unexpected) in 0.417 (0.438) seconds
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 2.1
  * frame #0: 0x000000012c8dcc53 AsyncDisplayKit`__ASInitializeFrameworkMainThreadOnDestructor_block_invoke(.block_descriptor=0x000000012cac8cb0) at ASInternalHelpers.mm:78:30
    frame #1: 0x000000010aef2a56 libdispatch.dylib`_dispatch_client_callout + 8
    frame #2: 0x000000010aef3ca5 libdispatch.dylib`_dispatch_once_callout + 20
    frame #3: 0x000000012c8dcc1c AsyncDisplayKit`ASInitializeFrameworkMainThreadOnDestructor [inlined] _dispatch_once(predicate=0x000000012cbe8498, block=0x000000012c8dcc40) block_pointer) at once.h:84:3
    frame #4: 0x000000012c8dcbdd AsyncDisplayKit`ASInitializeFrameworkMainThreadOnDestructor at ASInternalHelpers.mm:78:3
    frame #5: 0x000000012c883edb AsyncDisplayKit`ASLoadFrameworkInitializerOnDestructor() at ASDisplayNode.mm:267:3
    frame #6: 0x000000010afdb03c libsystem_c.dylib`__cxa_finalize_ranges + 409
    frame #7: 0x000000010afdb357 libsystem_c.dylib`exit + 22
    frame #8: 0x000000011cfe7749 XCTestCore`_XCTestMain + 125
    frame #9: 0x00000001089433ae xctest`main + 256
    frame #10: 0x0000000108952e1e dyld_sim`start_sim + 10

Copy link
Contributor

@rcancro rcancro left a comment

Choose a reason for hiding this comment

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

Thank you for the fix! Sorry for the delay!

@rcancro rcancro merged commit 053688b into TextureGroup:master Dec 3, 2021
@GeekTree0101 GeekTree0101 deleted the bug/Geektree0101/xcode-13 branch December 8, 2021 06:38
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

Successfully merging this pull request may close these issues.

None yet

8 participants