-
Notifications
You must be signed in to change notification settings - Fork 406
Closed
Description
What would you like to share?
I have changed some code in the repo, then I build aar to flutter project. I use the flutter sdk in locally. However, after I rebuild the flutter project, When I send Text message, it is ok, when it to picture, voices, I found a panic in my log.
And I try to find out why it happens,
func (c *Conversation) SendMessage(ctx context.Context, s *sdk_struct.MsgStruct, recvID, groupID string, p *sdkws.OfflinePushInfo, isOnlineOnly bool) (*sdk_struct.MsgStruct, error) {
filepathExt := func(name ...string) string {
for _, path := range name {
fmt.Println("filepathExt", path)
if ext := filepath.Ext(path); ext != "" {
fmt.Println("filepathExt ext", ext)
return ext
}
}
fmt.Println("filepathExt ext empty")
return ""
}
options := make(map[string]bool, 2)
lc, err := c.checkID(ctx, s, recvID, groupID, options)
if err != nil {
return nil, err
}
callback, _ := ctx.Value("callback").(open_im_sdk_callback.SendMsgCallBack)
log.ZDebug(ctx, "before insert message is", "message", *s)
if !isOnlineOnly {
oldMessage, err := c.db.GetMessage(ctx, lc.ConversationID, s.ClientMsgID)
if err != nil {
localMessage := MsgStructToLocalChatLog(s)
err := c.db.InsertMessage(ctx, lc.ConversationID, localMessage)
if err != nil {
return nil, err
}
err = c.db.InsertSendingMessage(ctx, &model_struct.LocalSendingMessages{
ConversationID: lc.ConversationID,
ClientMsgID: localMessage.ClientMsgID,
})
if err != nil {
return nil, err
}
} else {
if oldMessage.Status != constant.MsgStatusSendFailed {
return nil, sdkerrs.ErrMsgRepeated
} else {
s.Status = constant.MsgStatusSending
err = c.db.InsertSendingMessage(ctx, &model_struct.LocalSendingMessages{
ConversationID: lc.ConversationID,
ClientMsgID: s.ClientMsgID,
})
if err != nil {
return nil, err
}
}
}
lc.LatestMsg = utils.StructToJsonString(s)
log.ZDebug(ctx, "send message come here", "conversion", *lc)
_ = common.DispatchUpdateConversation(ctx, common.UpdateConNode{ConID: lc.ConversationID, Action: constant.AddConOrUpLatMsg, Args: *lc}, c.ConversationEventQueue())
}
var delFile []string
//media file handle
switch s.ContentType {
case constant.Picture:
if s.Status == constant.MsgStatusSendSuccess {
s.Content = utils.StructToJsonString(s.PictureElem)
break
}
var sourcePath string
if utils.FileExist(s.PictureElem.SourcePath) {
sourcePath = s.PictureElem.SourcePath
delFile = append(delFile, utils.FileTmpPath(s.PictureElem.SourcePath, c.DataDir))
} else {
sourcePath = utils.FileTmpPath(s.PictureElem.SourcePath, c.DataDir)
delFile = append(delFile, sourcePath)
}
log.ZDebug(ctx, "send picture", "path", sourcePath)
log.ZDebug(ctx, "send Picture", "s.PictureElem.SourcePicture.Type", s.PictureElem.SourcePicture.Type)
log.ZDebug(ctx, "send Picture", "s.PictureElem.SourcePicture.UUID", s.PictureElem.SourcePicture.UUID)
log.ZDebug(ctx, "send Picture", "c.file", c.file, "c is nil", c == nil, "file is nil", c.file == nil, "c.db", c.db == nil)
fmt.Printf("%#v\n", c.file)
res, err := c.file.UploadFile(ctx, &file.UploadFileReq{
ContentType: s.PictureElem.SourcePicture.Type,
Filepath: sourcePath,
Uuid: s.PictureElem.SourcePicture.UUID,
Name: c.fileName("picture", s.ClientMsgID) + filepathExt(s.PictureElem.SourcePicture.UUID, sourcePath),
Cause: "msg-picture",
}, NewUploadFileCallback(ctx, callback.OnProgress, s, lc.ConversationID, c.db))
.....func (f *File) UploadFile(ctx context.Context, req *UploadFileReq, cb UploadFileCallback) (*UploadFileResp, error) {
fmt.Println("UploadFile 1")
if cb == nil {
cb = emptyUploadCallback{}
}
fmt.Println("UploadFile 2", req.Name)
if req.Name == "" {
fmt.Println("UploadFile 3")
return nil, errors.New("name is empty")
}
log.ZDebug(ctx, "UploadFile", "req", req)
if req.Name[0] == '/' {
req.Name = req.Name[1:]
}
if prefix := f.loginUserID + "/"; !strings.HasPrefix(req.Name, prefix) {
req.Name = prefix + req.Name
}
log.ZDebug(ctx, "UploadFile", "req", req)
file, err := Open(req)
if err != nil {
log.ZDebug(ctx, "UploadFile", "open file", "xxxxxx")
return nil, err
}
defer file.Close()
fileSize := file.Size()
cb.Open(fileSize)
log.ZDebug(ctx, "UploadFile", "key", "11111")
info, err := f.getPartInfo(ctx, file, fileSize, cb)
if err != nil {
return nil, err
}
log.ZDebug(ctx, "UploadFile", "key", "22222")
...Then I test in project sdk-core, it is ok. But in flutter, I have logs below
I/GoLog ( 8794): 2025-08-13 03:00:10.185 DEBUG [PID:8794] [3.8.0] [flutter/Android] [conversation_msg/api.go:340] send picture {"operationID": "1755054010111", "path": "/data/user/0/io.openim.flutter.rtc.test/cache/1754136080244.jpg"}
I/GoLog ( 8794): 2025-08-13 03:00:10.186 DEBUG [PID:8794] [3.8.0] [flutter/Android] [conversation_msg/api.go:341] send Picture {"operationID": "1755054010111", "s.PictureElem.SourcePicture.Type": "image/jpeg"}
I/GoLog ( 8794): 2025-08-13 03:00:10.186 DEBUG [PID:8794] [3.8.0] [flutter/Android] [conversation_msg/api.go:343] send Picture {"operationID": "1755054010111", "s.PictureElem.SourcePicture.UUID": ""}
I/GoLog ( 8794): 2025-08-13 03:00:10.186 DEBUG [PID:8794] [3.8.0] [flutter/Android] [conversation_msg/api.go:344] send Picture {"operationID": "1755054010111", "c.file": {}, "c is nil": false, "file is nil": false, "c.db": false}
I/GoLog ( 8794): &file.File{database:(*db.DataBase)(0x40000ee8c0), loginUserID:"8471770836", confLock:(*sync.Mutex)(0x4000450628), partLimit:(*third.PartLimitResp)(nil), mapLocker:(*sync.Mutex)(0x4000450630), uploading:map[string]*file.lockInfo{}}
I/GoLog ( 8794): filepathExt
I/GoLog ( 8794): filepathExt /data/user/0/io.openim.flutter.rtc.test/cache/1754136080244.jpg
I/GoLog ( 8794): filepathExt ext .jpg
I/GoLog ( 8794): panic err: runtime error: invalid memory address or nil pointer dereference goroutine 345 [running]:
I/GoLog ( 8794): runtime/debug.Stack()
I/GoLog ( 8794): runtime/debug/stack.go:26 +0x64
I/GoLog ( 8794): github.com/openimsdk/openim-sdk-core/v3/open_im_sdk.messageCall_.func1()
I/GoLog ( 8794): github.com/openimsdk/openim-sdk-core/v3@v3.0.0-00010101000000-000000000000/open_im_sdk/caller.go:371 +0x48
I/GoLog ( 8794): panic({0x7d95ff0e60?, 0x7d967452a0?})
I/GoLog ( 8794): runtime/panic.go:792 +0x124
I/GoLog ( 8794): github.com/openimsdk/openim-sdk-core/v3/internal/conversation_msg.(*Conversation).SendMessage(0x40003d4d80, {0x7d9614e988, 0x400069a360}, 0x400013e780, {0x400089cc10, 0xa}, {0x0, 0x0}, 0x40002fe300, 0x0)
I/GoLog ( 8794): github.com/openimsdk/openim-sdk-core/v3@v3.0.0-00010101000000-000000000000/internal/conversation_msg/api.go:352 +0xb10
I/GoLog ( 8794): reflect.Value.call({0x7d96025ac0?, 0x400022c7a0?, 0x40002d0820?}, {0x7d95db16a1, 0x4}, {0x4000352240, 0x6, 0x400021a000?})
I/GoLog ( 8794): reflect/value.go:584 +0x978
I/GoLog ( 8794): reflect.Value.Call({0x7d96025ac0?, 0x400022c7a0?, 0x4000829e30?}, {0x4000352240?, 0x4?, 0x400068c780?})
I/GoLog ( 8794): reflect/value.go:368 +0x94
I/GoLog ( 8794): github.com/openimsdk/openim-sdk-core/v3/open_im_sdk.messageCall_({0x7d9614cde8, 0x400089cbfc}, {0x400089cc00, 0xd}, {0x7d96025ac0, 0x400022c7a0}, {0x40001b02d0, 0x5, 0x5})
I/GoLog ( 8794): github.com/openimsdk/openim-sdk-core/v3@v3.0.0-00010101000000-000000000000/open_im_sdk/caller.go:448 +0xec4
I/GoLog ( 8794): created by github.com/openimsdk/openim-sdk-core/v3/open_im_sdk.messageCall in goroutine 17
I/GoLog ( 8794): github.com/openimsdk/openim-sdk-core/v3@v3.0.0-00010101000000-000000000000/open_im_sdk/caller.go:366 +0xf0
I/GoLog ( 8794):
I/F-OpenIMSDK(flutter call native)( 8794): { class:imManager, method:logs }
I/GoLog ( 8794): 2025-08-13 03:00:10.189 INFO [PID:8794] [3.8.0] [flutter/Android] [open_im_sdk/caller.go:118] func call req {"operationID": "1755054010171", "function name": "github.com/openimsdk/openim-sdk-core/v3/internal/third.(*Third).Log-fm", "args": [5,"",0,"2025-08-13T11:00:10.170588 [*flutter*Android/29] []: message clientMsgID: 78911f010368714e0ff61c6cf3b574e2, ","","[]"]}
I/GoLog ( 8794): 2025-08-13 03:00:10.189 INFO [PID:8794] [3.8.0] [flutter/Android] [open_im_sdk/caller.go:109] fn call success {"operationID": "1755054010171", "function name": "github.com/openimsdk/openim-sdk-core/v3/internal/third.(*Third).Log-fm", "cost time": "0 ms", "resp": ""}
I/F-OpenIMSDK(native call flutter)( 8794): thread: Thread-8 method: 【 logs 】, onSuccess: ""
I/F-OpenIMSDK(flutter call native)( 8794): { class:imManager, method:logs }
Then I have no idea about why this will panic,
Additional information
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels