wabiverse / Kraken

Kraken, is the free and open source metaversal creation suite.
https://wabi.foundation
GNU General Public License v3.0
16 stars 5 forks source link

Opening some USD files can crash Kraken. #12

Open Marti-S opened 2 months ago

Marti-S commented 2 months ago

This bug usually occurs after a few times of opening different USD files.

Screenshot_2024-04-17_at_12 14 12
furby-tm commented 2 months ago

It appears this might be directly related to a missing asset that used to exist on your machine, which got baked into the (.usd) file upon saving from the DCC program in which saved it out, the file that it appears to be looking for is at the following file path:

/Users/marti/Documents/00_Afloat/AndorWorld/Characters/Assemblies/Alya/USD/Alya_SurvivalPants.usdc

However, the lack of this file existing should not typically correlate to a crash, and should therefore be fixed.

There are some issues currently when attempting to open some specific USD files with Kraken because I'm temporarily utilizing Apple's SceneKit.SceneView which offers quite a few limitations with USD.

I'm currently working on completely moving away from any of Apple's proprietary frameworks (fortunately this is the only one being utilized at the moment), now that I have all of SwiftUSD at my disposal, to provide a cross-platform open source alternative to Apple's SceneKit, (disregarding Apple specific API such as .scn and so fourth) by creating a more USD-oriented API design, which I expect to clean inconsistencies like this up.

furby-tm commented 2 months ago

@stackotter Also I will focus on ensuring this open source framework alternative to SceneKit, (named HydraKit, which seems appropriate given its USD oriented approach) will work with each of SwiftCrossUI's backends, so that SwiftUI can be easily utilized in a same cross-platform way, example:

import SwiftCrossUI
import PixarUSD
import HydraKit

/**
 * A full UsdView-like application
 * that users can implement, and to
 * do so in only ~10 lines of code. */

@main
struct Kraken: App
{
  @State var stage: UsdStageRefPtr

  init()
  {
    /* setup usd plugins & resources. */
    Pixar.Bundler.shared.setup(.resources)

    stage = Usd.Stage.createNew("Untitled", ext: .usd)
  }

  var body: some Scene
  {
    DocumentGroup(newDocument: Kraken.IO.USD())
    { usdFile in
      HStack
      {
        HydraView(stage: $stage)
          .onChange(of: usdFile)
          {
            stage = Usd.Stage.open(usdFile)
          }
      }
    }
  }
}

The question there is should this be apart of the SwiftUSD package, or in its own?

Which especially for this use case, brings me to one additional nice feature improvement proposal for SwiftCrossUI, which is to implement an equivalent DocumentGroup(newDocument:) for that package (read more about this API here), it would definitely help for use cases such as these.

Marti-S commented 2 months ago

If I have a vote, I will vote yes for this proposal.

stackotter commented 2 months ago

I love the idea of HydraKit integrating with SwiftCrossUI, I've been waiting for an opportunity to figure out how 3rd party libraries can work with individual backends to provide new native views (and preferably without having to provide a separate target for each backend, but that may be the case for now).

The question there is should this be apart of the SwiftUSD package, or in its own?

I reckon it should be separate, no one's ever gonna find out about anything if it's all in the monolithic SwiftUSD repo.

Which especially for this use case, brings me to one additional nice feature improvement proposal for SwiftCrossUI, which is to implement an equivalent DocumentGroup(newDocument:) for that package (read more about this API here), it would definitely help for use cases such as these.

That would definitely be nice to have, but it'll require quite a bit of platform-specific stuff for things like menus and file dialogs so I'll need to add support for those to the 3 main backends first.