Unity-Technologies / Unity-Technologies/UnityDataTools
Handler Finalize() methods are never called, so intended indexes are never created
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- C#
- Estrellas
- 821
- Forks
- 71
- Merge medio
- 3 h 13 min
- PR fusionados (30 d)
- 9
Descripción
Summary
The ISQLiteHandler implementations each define a public void Finalize(SqliteConnection db) method, but nothing ever calls it. Finalize is not part of the ISQLiteHandler interface (which only declares Init, Process, and Dispose), and there is no dispatch site anywhere in the codebase. As a result, the finalization work in those methods never runs.
For most handlers the method is an empty stub, but two of them create indexes that are therefore never created:
AssetBundleHandler.Finalize->preload_dependencies_object,preload_dependencies_dependencyShaderHandler.Finalize->shader_subprograms_shader_index,shader_subprogram_keywords_subprogram_id_index
(Note: SQLiteWriter.End() runs Resources.Finalize / Finalize.sql, which creates the refs indexes. That is a separate, top-level mechanism and does run - it is unrelated to these per-handler Finalize methods.)
Impact
- The four indexes above are missing from every analyze database, so queries that filter/join on
preload_dependencies(object),preload_dependencies(dependency),shader_subprograms(shader), andshader_subprogram_keywords(subprogram_id)do full scans. This is a performance issue only; results are still correct. - The empty
Finalizestubs in the other handlers are dead code and misleadingly imply a finalization step exists.
Evidence
After running analyze on TestCommon/Data/LeadingEdgeBuilds/AssetBundles:
sqlite> SELECT name FROM sqlite_master WHERE type='index' AND name LIKE 'preload_%';
-- (no rows)
The preload_dependencies table and its data are present, but the indexes are not.
Affected files
Analyzer/SQLite/Handlers/ISQLiteHandler.cs- interface has noFinalize.- Non-empty bodies:
Analyzer/SQLite/Handlers/AssetBundleHandler.cs,Analyzer/SQLite/Handlers/ShaderHandler.cs. - Empty stubs:
AnimationClipHandler.cs,AudioClipHandler.cs,BuildReportHandler.cs,MeshHandler.cs,MonoScriptHandler.cs,PackedAssetsHandler.cs,PreloadDataHandler.cs,Texture2DHandler.cs.
Suggested fix
Either:
-
Wire it up - add
Finalize(SqliteConnection db)toISQLiteHandlerand invoke it once per handler after all serialized files are processed (the handler lifecycle is owned bySerializedFileSQLiteWriter;SQLiteWriter.End()is the natural point at which finalization runs). Drop the now-redundant empty overrides where possible. This restores the four intended indexes. -
Delete the dead code - if the indexes are not wanted, remove all the
Finalizemethods.
Option 1 is preferred since the indexes are clearly intended and benefit lookups on the dependency and shader-subprogram tables.
Notes
The two preload_dependencies_* index names were just updated in #82 (table rename); this bug predates that change - the indexes were never created under their old asset_dependencies_* names either.
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza con Analyzer/SQLite/Handlers/ISQLiteHandler.cs y el ciclo de vida de los handlers en SerializedFileSQLiteWriter; inspecciona SQLiteWriter.End() como el punto de entrada propuesto para la finalización. Traza cómo se procesan los handlers y, a continuación, verifica la finalización comprobando que los cuatro índices previstos aparecen en la base de datos de análisis y que los stubs vacíos obsoletos se gestionan de forma coherente.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- csharp, sqlite
- Área
- databases
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Tranquilo
- Claridad
- Bastante claro
- Aptitud para principiantes
- 55/100