-
Notifications
You must be signed in to change notification settings - Fork 113
COCOA 突如として初期化される問題(UserDataが壊れている) #16
Comments
COCOA のログの出力は、
で、保存された内容を確認しています。 |
2021/01/21 付けの報道ステーションで取り上げられたので、ログ取得の手順をあげておきます。
保存された情報は、iPhone であれば「ファイル」アプリを起動して、接触確認アプリのフォルダーで見れます。 このデータを iTunes などを使って取り出せばよいでしょう。 なお、実際に、厚生労働省に送信するときは、あらかじめメールアプリの設定が必要です。 という案内が公式にあったほうが良いと思います。 |
厚労省サポートさんへ動作情報(ログ)を送信する手順をここに追記しておきます。 |
横から失礼します🙇♂️ ExposureNotificationHandler.DownloadBatchAsync で例外が発生している原因について、少し調べてみました。結論からすると ExposureNotificationHandler のフィールド
注目したのはこのログです。 「"End","GetTemporaryExposureKeyList"」のログの直後すぐに NullReferenceException をキャッチした旨のログがあり、「tekItem.Created: ...」というログが無いので、ソースの以下の範囲内で NullReferenceException が発生し、ExposureNotificationHandler.DownloadBatchAsync が例外終了したように見えます。 cocoa/Covid19Radar/Covid19Radar/Services/ExposureNotificationHandler.cs Lines 226 to 248 in 36b1a07
ログには「"End","GetTemporaryExposureKeyList"」とあるので、行 226 の HttpDataService.GetTemporaryExposureKeyList の呼び出しは成功し、また NullReferenceException は発生しません。その後、NullReferenceException が発生する可能性がある行は以下の通りです。
このうち最も可能性が高いのは 2 個目の cocoa/Covid19Radar/Covid19Radar/Services/UserDataService.cs Lines 65 to 79 in 36b1a07
注目したログの時点で |
アプリがリセットされた皆さま、可能であればexistsUserData: Falseが記録される「前」のログを共有していただけないでしょうか。
下記のように、SetAsyncのEndが呼ばれる前にアプリがterminateされた次の起動で消えているようなので、SetAsync内の保存操作が完了する前にterminateされるとデータが消えるのではないかと疑っています。
具体的にはXamarin.FormsのSavePropertiesAsyncの実装が
という三段階になっており、2と3の間でiOSがバックグラウンド動作時間超過などでアプリをterminateすると消える可能性がゼロではないように見えます。 |
あ、すみませんSetAsyncの部分だけ違いますね・・上記のログでは よく見るとGetExposureNotificationConfigもEndになっておらず↓
GetExposureNotificationConfigの中でSavePropertiesAsyncを呼び出していました。
このEndMethodが呼ばれる前にterminateされているので、SavePropertiesAsyncの途中でプロセスが落ちてしまった→tmpファイルを残してProperties全体が消えてしまった可能性がありそうです。 |
ちょうど一昨日手元の iPhone で初期化を確認したのでログを取得できました。
前日のログ cocoa_log_20210202.csv の終端を見てみると……
と、ここで唐突に終わっています。中途半端なところで terminate された感はありますね。 |
@yozjp ありがとうございます! DownloadBatchAsyncで止まってるようにも見えますが、ログを1行ずつ突き合わせると
の後にGetExposureNotificationConfigの中で
が呼ばれてますが、その直後のSavePropertiesAsyncの後に呼ばれるはずの
に該当するログがないようですね。わたしのパターンと同じのように見受けられます。 |
実際にXamarin.Formsのコードのこの位置にbreakpointを差し込んでやってみて、この位置でアプリが落ちるとデータが消えてしまうことが確認できました。 COCOA自体をデバッグ用に準備する手順は下記のとおりです。(すでにデバッグ実行できる場合は、デバッグソースファイルを追加するだけでOKです)
ここまでセットアップしたら、下記の手順で再現させます。
再度起動した際のログは下記の通りで、existsUserData: Falseとなっていることが確認できました。
|
(質問をいただいたので追記)該当箇所はAndroidもiOSも影響を受けていそうですが、iOSだけ報告が多い理由は、通知などからのバックグラウンド実行(してるかは未確認)に厳しい時間制限(強制終了)があったはずで、おそらくそのタイミングと運悪く重なっているのではと推測しています。Androidはスリープはされてもメモリ不足にならない限りkillされない記憶です。 |
Android版はバックグラウンド実行がまともに動いていないからではないでしょうか。 |
xamarin/Xamarin.Forms#13676 で報告されている #16 (comment) のログは、
どちらも End はなし。 #16 (comment) のログは、
どちらも End はなし。 となっており、 あるいは ※追記 あ、 Xamarin.iOS や Xamarin.Android の |
同時に書き込むと例外が発生する、という問題が以前にあって今はセマフォで排他制御をしているようです。 |
なるほど、 |
@moonmile さんはじめ皆さま、Issueコメント、さまざまな原因調査・検証のご協力ありがとうございます。 @ypresto さんご指摘の通り、厚生労働省でもXamarin.Formsの該当箇所でアプリが落ちた場合にデータ消失が発生することを確認しており、今回以下の通り対策を講じました。また、iOSにおいて発生している問題でしたが、今回iOS/Android双方で同様に処理を変更しています。 具体的には、データ保存について、Xamarin.FormsではなくiOS/AndroidのNative APIを使用するよう変更し、データ保存は同期処理として、かつ保存処理時に排他制御をかけています。 この上で同様の不具合が継続して発生する場合は、更なる検証、対応を進めます。 |
1月4日の突如として COCOA の継続日数が初期化されました。
初期化された後、再び同意をして使用を継続しているのですが、ログを見ていくと、初期化される前に常に
"existsUserData: False" な状態になっています。
この状態が、1/4 まで続きます。
同意をすると、再び "existsUserData: True" な状態になります。
この動作は想定されているものでしょうか?
The text was updated successfully, but these errors were encountered: