Skip to content

StringIndexOutOfBoundsException on firestore API with unicode character #900

@Thaina

Description

@Thaina

[REQUIRED] Please fill in the following fields:

  • Unity editor version: 2016.1
  • Firebase Unity SDK version: 7.0.1 (suspect since 7.0.0)
  • Source you installed the SDK: UPM
  • Problematic Firebase Component: FireStore
  • Other Firebase Components in use: Auth,Analytics,Crashlytics,DynamicLinks,Messaging
  • Additional SDKs you are using: Facebook, Admob, OneSignal
  • Platform you are using the Unity editor on: Windows
  • Platform you are targeting: Android
  • Scripting Runtime: IL2CPP

[REQUIRED] Please describe the issue here:

There are weird error in android when using firebase 7.0.1, which is not occur in 6.16.1 when there is unicode character in firestore document

Steps to reproduce:

  • Making a firestore document with some unicode character, for example

image

  • Listening to collection query normally and just try to access field with unicode

  • It then error like this

12-16 12:14:10.776 12841 12993 W System.err: java.lang.StringIndexOutOfBoundsException: offset=0 length=8 string.length()=4
12-16 12:14:10.776 12841 12993 W System.err: 	at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
12-16 12:14:10.776 12841 12993 W System.err: 	at com.unity3d.player.UnityPlayer.access$300(Unknown Source:0)
12-16 12:14:10.776 12841 12993 W System.err: 	at com.unity3d.player.UnityPlayer$e$1.handleMessage(Unknown Source:95)
12-16 12:14:10.776 12841 12993 W System.err: 	at android.os.Handler.dispatchMessage(Handler.java:103)
12-16 12:14:10.776 12841 12993 W System.err: 	at android.os.Looper.loop(Looper.java:214)
12-16 12:14:10.776 12841 12993 W System.err: 	at com.unity3d.player.UnityPlayer$e.run(Unknown Source:20)
  • In this case it error from "message" : "محمد" but also happen to emoji too. Maybe any unicode would be the same problem

Relevant Code:

collection.Listen((messages) => {
	var messageTexts = messages.Documents.Select((doc) => {
		try
		{
			Debug.LogFormat("Message : {0}",doc.Id); // debug can still log this line
			if(doc.TryGetValue<string>("message",out var message)) // error around this line
				Debug.LogFormat("MessageType : {0}",message);
			return message;
		}
		catch(Exception e)
		{
			Debug.LogException(e);
			throw;
		}
	}).ToArray();

	// do something
});

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions