Code Monkey home page Code Monkey logo

Comments (9)

nirinchev avatar nirinchev commented on July 19, 2024 1

A similar crash report can be found here #5618 where the issue appears to be caused by FirebasePerformance. There are several workarounds suggested there, notably rather than rely on automatic schema discovery, you can explicitly specify the objectClasses field in your configuration.

I'll close the issue due to lack of information, but if you do come back to it and keep seeing it after trying the suggested workarounds, feel free to reopen.

from realm-swift.

GengJian avatar GengJian commented on July 19, 2024 1

It works!!

from realm-swift.

Jaycyn avatar Jaycyn commented on July 19, 2024

Can you please provide a minimal but complete coding sample that replicates the crash?

from realm-swift.

GengJian avatar GengJian commented on July 19, 2024

// MARK: - Property

#if DEBUG
    private static let realmName = "localDB.realm"
#else
    private static let realmName = "defaultDB.realm"
#endif

// MARK: - Init Func

 func initDefaultConfig() {
        guard let documentsURL = FileManager.default.urls(
           for: .documentDirectory,
           in: .userDomainMask
       ).first else {
           return
       }

let dbPath = documentsURL.appendingPathComponent(realmName)
       let config = Realm.Configuration(
           fileURL: dbPath,
           schemaVersion: 3
       ) { migration, oldSchemaVersion in
           if oldSchemaVersion < 2 {
               migration.enumerateObjects(ofType: VSTempHumiRecord.className()) { oldObject, newObject in
                   newObject?.inTemp = oldObject?.inTemp
                   newObject?.outTemp = oldObject?.outTemp
                   newObject?.inHumi = oldObject?.inHumi
                   newObject?.outHumi = oldObject?.outHumi
                   if oldObject?.isSynced == nil {
                       newObject?.isSynced = false
                   }
               }
           }

           if oldSchemaVersion < 3 {
               migration.enumerateObjects(ofType: VSTempHumiRecord.className()) { oldObject, newObject in
                   newObject?.bTemp = oldObject?.inTemp
                   newObject?.bHumi = oldObject?.inHumi
                   newObject?.pTemp = oldObject?.outTemp
                   newObject?.pHumi = oldObject?.outHumi
               }
           }
       }
       Realm.Configuration.defaultConfiguration = config
       Realm.asyncOpen { result in
           switch result {
           case .success(let realm):
               print(self, realm)
           case .failure(let error):
               print(self, error)
           }
       }
   }

from realm-swift.

GengJian avatar GengJian commented on July 19, 2024
public class VSTempHumiRecord: Object {
    @Persisted(primaryKey: true) var unionPrimaryKey: String = ""
    @Persisted var showDate: Date?
    @Persisted var cFanlv: Int?
    @Persisted var dFanlv: Int?
    @Persisted var lightlv: Int?
    @Persisted var inHumi: Int? = 0
    @Persisted var inTemp: Int? = 0
    @Persisted var outHumi: Int? = 0
    @Persisted var outTemp: Int? = 0
    @Persisted var bHumi: Int?
    @Persisted var bTemp: Int?
    @Persisted var pHumi: Int?
    @Persisted var pTemp: Int?
    @Persisted var time = 0
    @Persisted var deviceId = ""
    @Persisted var isSynced = false
}

from realm-swift.

nirinchev avatar nirinchev commented on July 19, 2024

I have tried to copy your code in a brand new project, ran it, and didn't get any crashes. You can find the project I used attached to this comment. If you're able to modify the project I supplied or provide us with a project that actually reproduces the problem, we'll be able to continue the investigation.

Issue8491-ios.zip

from realm-swift.

GengJian avatar GengJian commented on July 19, 2024

It may be that in the demo there is no historical data so there will be no time-consuming operation.

However, in the specific project( on-line release version), our firebase crashlytics in general prompts are triggered within 1-2s of app startup.

So I would like to ask the crash caused by initialization migration operation initDefaultConfig written in appdelegate. didFinshLaunching

from realm-swift.

Jaycyn avatar Jaycyn commented on July 19, 2024

When you add a breakpoint to your code, and then run the project and step through it line by line, what line is crashing? Which variables are not as expected?

from realm-swift.

nirinchev avatar nirinchev commented on July 19, 2024

@GengJian it may very well be the historical data on the device, but unless we're able to repro the crash or get more information about it, there's not much we can do. My point was that I tried to repro with the code you provided and things work correctly for me. If you're able to give us more details or a repro case we can run locally, then I'd be happy to continue investigating.

from realm-swift.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.