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

[RLMSchema] Don't iterate through runtime classes unnecessarily #8721

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ajjnix
Copy link

@ajjnix ajjnix commented Nov 25, 2024

In my application, there are quite a few crashes with an unclear stack trace (see the screenshot). During my investigation, I found out what is happening:

  1. We add a class to Realm.
  2. We release a version.
  3. We remove the class from the application's source code.
  4. In the migration, we call deleteData(forType:). Yes, I am aware of the crosslink issue; this is not that situation. I will look into that MR later with my experience on how to fix the deletion problem.
  5. deleteData(forType:) tries to determine whether to clear or delete the table.
  6. To do this, it calls -schemaForClassName (RLMSchema).
  7. I have explicitly defined all classes (in objectSchemaByName after +(instancetype)schemaWithObjectClasses), and none of them includes the one I'm deleting, which makes sense.
  8. But it seems excessive that a search is performed in +classForString (RLMSchema), which then goes to RLMRegisterClassLocalNames and iterates through all classes. And I remind you that I have explicitly specified the ones I am using.
  9. We end up in RLMIsObjectSubclass.
  10. And already in class_getSuperclass, something goes wrong.

I understand that it would be good to figure out which specific class is causing this issue, but I don't have that capability. However, it seems that this MR will eliminate the need to call class_getSuperclass unnecessarily.
Screenshot 2024-11-25 at 23 19 24

@ajjnix ajjnix changed the title Don't iterate through runtime classes unnecessarily [RLMSchema] Don't iterate through runtime classes unnecessarily Nov 25, 2024
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.

1 participant