TextureGroup / Texture

Smooth asynchronous user interfaces for iOS apps.
https://texturegroup.org/
Other
8.02k stars 1.29k forks source link

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

Closed GeekTree0101 closed 2 years ago

GeekTree0101 commented 3 years ago

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

https://github.com/TextureGroup/Texture/pull/2032/commits/a366b40c176e6987b8a0aff9e404fbf347daf475

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

https://github.com/TextureGroup/Texture/pull/2032/commits/28d87067b66a0dfc0c98ead67cf2fb65b8352efe

Loaded node of contentsScale must be 2.0 on layer backed

https://github.com/TextureGroup/Texture/pull/2032/commits/01e47e3863e1825fa834cc931272acfec2c681d8 Creating layers (not created via a UIView), node need to set their scale manually. Usually this is just layer.contentsScale = [[UIScreen mainScreen] scale].

GeekTree0101 commented 3 years ago

test failed

result

addition

ghost commented 3 years ago

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

GeekTree0101 commented 3 years ago

I'm also curious too

frugoman commented 3 years ago

Anything needed to be done to have this merged?

genry86 commented 3 years ago

Any progress?

ghost commented 3 years ago

@nguyenhuy @rcancro please have a look here 🙏

mattrobmattrob commented 3 years ago

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