nathantannar4 / Transmission

Bridges UIKit presentation APIs to a SwiftUI API so you can use presentation controllers, interactive transitions and more.
BSD 2-Clause "Simplified" License
378 stars 13 forks source link

`window` modifier with Optional binding locks up or crashes #12

Closed kdubb closed 10 months ago

kdubb commented 10 months ago

Using a window modifier like the following:

.window(callManagerUI.bindToCurrentActiveCall().animation(),
        level: .overlay,
        transition: .move(edge: .top)) { activeCallBinding in

  CallHUDView(activeCall: activeCallBinding.wrappedValue)
    .environmentObject(callManagerUI)
}

Setting currentActiveCall to .some(call) (which is what bindToCurrentActiveCall() is reading/writing) properly shows the overlay banner at the top (including the transition). Then, setting currentActiveCall to nil removes the overlay banner (including the transition). All seems/looks good.

Continuing to "toggle" currentActiveAll causes a complete lockup of the UI or it just crashes.

Edit: It seems to be happening in this order.. show -> hide -> show -> crash on hide

Edit 2: I am using tagged version 1.0.0

kdubb commented 10 months ago

Not a lot of info to be gleaned from the stack...

Screenshot 2023-11-03 at 10 41 21 AM
kdubb commented 10 months ago

Better stack trace showing that it appears to be starting from UIWindow dealloc...

Screenshot 2023-11-03 at 10 47 10 AM Screenshot 2023-11-03 at 10 47 53 AM Screenshot 2023-11-03 at 10 48 04 AM
kdubb commented 10 months ago

Enabling "Address Sanitizer" and "Malloc Scribble"... I get a "Heap buffer overflow" on the second "show" (show -> hide -> show (heap buffer overflow)

Screenshot 2023-11-03 at 10 54 50 AM

To highlighted source code ViewInputs.swift:210:

Screenshot 2023-11-03 at 10 58 12 AM
kdubb commented 10 months ago

Address sanitizer report for above crash...

thread #1: tid = 0x7000f4, 0x0000000107e1d1dc libclang_rt.asan_ios_dynamic.dylib`__asan::AsanDie(), queue = 'com.apple.main-thread', stop reason = Heap buffer overflow
{
  "access_size": 8,
  "access_type": 0,
  "address": 4498768208,
  "description": "heap-buffer-overflow",
  "instrumentation_class": "AddressSanitizer",
  "pc": 4306300644,
  "stop_type": "fatal_error"
}
nathantannar4 commented 10 months ago

Please make sure Engine is using 1.0.0 with commit 7f781a82725d72e51377a2ee4e167904fab501f9. You may need to re-resolve your projects swift packages.

kdubb commented 10 months ago

It is confirmed. I set the minimum to 1.0.0 when adding the package(s).

Additionally, I just removed and re-added the package and confirmed the exact same crash with address sanitizer enabled.

Here's the dependency

Screenshot 2023-11-03 at 3 34 43 PM
nathantannar4 commented 10 months ago

You seem to have the pre-release version of 1.0.0 cached on your system.

To reset the cache for a single package:

Then in Xcode, File > Packages > Reset Package Caches

kdubb commented 10 months ago

@nathantannar4 You were correct. I checked the Package.resolved and saw a different commit hash. After resetting my package cache it resolved to the commit you referenced and all seems to work!

Apologies I should probably have checked the resolved commit hash first with Xcode's fragile SPM integration.

Thanks for the help and the great library!